}
[Fact]
+ public void ToString_Test()
+ {
+ var datetime = new DateTime(2018, 5, 6, 11, 22, 33, 111, DateTimeKind.Utc);
+ var utc = new DateTimeUtc(datetime);
+
+ Assert.Equal(datetime.ToString(), utc.ToString());
+ }
+
+ [Fact]
public void ToString_FormatTest()
{
var utc = new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111);
}
[Fact]
- public void ToLocalString_FormatTest()
+ public void ToLocalTimeString_Test()
+ {
+ var datetime = new DateTime(2018, 5, 6, 11, 22, 33, 111, DateTimeKind.Local);
+ var utc = new DateTimeUtc(datetime.ToUniversalTime());
+
+ Assert.Equal(datetime.ToString(), utc.ToLocalTimeString());
+ }
+
+ [Fact]
+ public void ToLocalTimeString_FormatTest()
{
var localDatetime = new DateTime(2018, 5, 6, 11, 22, 33, 111, DateTimeKind.Local);
var utc = new DateTimeUtc(localDatetime.ToUniversalTime());
=> this.datetime.GetHashCode();
public override string ToString()
- => this.ToDateTimeOffset().ToString();
+ => this.ToString("G");
public string ToString(string format)
=> this.ToDateTimeOffset().ToString(format);
+ public string ToLocalTimeString()
+ => this.ToLocalTimeString("G");
+
public string ToLocalTimeString(string format)
=> this.ToLocalTime().ToString(format);
private ListViewItem CreateListViewItem(Twitter.FormattedEvent source)
{
- string[] s = { source.CreatedAt.ToString(), source.Event.ToUpper(CultureInfo.CurrentCulture), source.Username, source.Target };
+ string[] s = { source.CreatedAt.ToLocalTimeString(), source.Event.ToUpper(CultureInfo.CurrentCulture), source.Username, source.Target };
return new ListViewItem(s);
}
foreach (Twitter.FormattedEvent _event in source)
{
sw.WriteLine(_event.Eventtype + "\t" +
- "\"" + _event.CreatedAt + "\"\t" +
+ "\"" + _event.CreatedAt.ToLocalTimeString() + "\"\t" +
_event.Event + "\t" +
_event.Username + "\t" +
_event.Target + "\t" +
public class FormattedEvent
{
public MyCommon.EVENTTYPE Eventtype { get; set; }
- public DateTime CreatedAt { get; set; }
+ public DateTimeUtc CreatedAt { get; set; }
public string Event { get; set; }
public string Username { get; set; }
public string Target { get; set; }
{
Eventtype = MyCommon.EVENTTYPE.Retweet,
Event = "retweet",
- CreatedAt = MyCommon.DateTimeParse(xElm.XPathSelectElement("/created_at").Value),
+ CreatedAt = new DateTimeUtc(MyCommon.DateTimeParse(xElm.XPathSelectElement("/created_at").Value).ToUniversalTime()),
IsMe = xElm.XPathSelectElement("/user/id_str").Value == this.UserId.ToString(),
Username = xElm.XPathSelectElement("/user/screen_name").Value,
Target = string.Format("@{0}:{1}", new[]
}
var evt = new FormattedEvent();
- evt.CreatedAt = MyCommon.DateTimeParse(eventData.CreatedAt);
+ evt.CreatedAt = new DateTimeUtc(MyCommon.DateTimeParse(eventData.CreatedAt).ToUniversalTime());
evt.Event = eventData.Event;
evt.Username = eventData.Source.ScreenName;
evt.IsMe = evt.Username.ToLowerInvariant().Equals(this.Username.ToLowerInvariant());