}
[Fact]
+ public void ToString_FormatTest()
+ {
+ var utc = new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111);
+
+ Assert.Equal("2018-05-06 11:22:33.111 +00:00", utc.ToString("yyyy-MM-dd HH:mm:ss.fff zzz"));
+ }
+
+ [Fact]
+ public void ToLocalString_FormatTest()
+ {
+ var localDatetime = new DateTime(2018, 5, 6, 11, 22, 33, 111, DateTimeKind.Local);
+ var utc = new DateTimeUtc(localDatetime.ToUniversalTime());
+
+ Assert.Equal(localDatetime.ToString("O"), utc.ToLocalTimeString("O"));
+ }
+
+ [Fact]
public void OperatorPlus_Test()
{
var utc = new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111);
public override int GetHashCode()
=> this.datetime.GetHashCode();
+ public override string ToString()
+ => this.ToDateTimeOffset().ToString();
+
+ public string ToString(string format)
+ => this.ToDateTimeOffset().ToString(format);
+
+ public string ToLocalTimeString(string format)
+ => this.ToLocalTime().ToString(format);
+
public static DateTimeUtc operator +(DateTimeUtc a, TimeSpan b)
=> new DateTimeUtc(a.datetime + b);
this.UserProfile.Text = user.Description;
if (!String.IsNullOrEmpty(user.RecentPost))
{
- this.UserTweetDateTime.Text = user.PostCreatedAt.ToString("yy/MM/dd HH:mm");
+ this.UserTweetDateTime.Text = user.PostCreatedAt.ToLocalTimeString("yy/MM/dd HH:mm");
this.UserTweet.Text = user.RecentPost;
}
else
this.Protect = user.Protected;
this.FriendsCount = user.FriendsCount;
this.FollowersCount = user.FollowersCount;
- this.CreatedAt = MyCommon.DateTimeParse(user.CreatedAt);
+ this.CreatedAt = new DateTimeUtc(MyCommon.DateTimeParse(user.CreatedAt).ToUniversalTime());
this.StatusesCount = user.StatusesCount;
this.Verified = user.Verified;
if (user.Status != null)
{
this.RecentPost = user.Status.FullText;
- this.PostCreatedAt = MyCommon.DateTimeParse(user.Status.CreatedAt);
+ this.PostCreatedAt = new DateTimeUtc(MyCommon.DateTimeParse(user.Status.CreatedAt).ToUniversalTime());
this.PostSource = user.Status.Source;
}
}
public int FriendsCount = 0;
public int FollowersCount = 0;
public int FavoriteCount = 0;
- public DateTime CreatedAt = new DateTime();
+ public DateTimeUtc CreatedAt;
public int StatusesCount = 0;
public bool Verified = false;
public string RecentPost = "";
- public DateTime PostCreatedAt = new DateTime();
+ public DateTimeUtc PostCreatedAt;
public string PostSource = ""; // html形式 "<a href="http://sourceforge.jp/projects/tween/wiki/FrontPage" rel="nofollow">Tween</a>"
public bool isFollowing = false;
public bool isFollowed = false;