public DynamoDBEntry ToEntry(object value) { long num = (long)value; return(new Primitive { Value = ServiceUtilities.ConvertFromUnixTimestamp(num).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") }); }
public void TestDateTimeConverterTo() { // ARRANGE long time = 1525914401; DateTime dt = ServiceUtilities.ConvertFromUnixTimestamp(time); TimestampConverter converter = new TimestampConverter(); // ACT DynamoDBEntry data = converter.ToEntry(time); // ASSERT Assert.Equal(dt, DateTime.Parse(data.AsString()).ToUniversalTime()); }
public void DateMismatchTest() { // ARRANGE DashboardEventRaw ev = JsonConvert.DeserializeObject <DashboardEventRaw>(File.ReadAllText("date_mismatch.json")); DateTime dt = ServiceUtilities.ConvertFromUnixTimestamp(Int64.Parse(ev.Date)); // ACT DateTime baseDate = EventTimelineUtilities.GetBaseDate(ev); // ASSERT Assert.Equal(new DateTime(2019, 5, 10, 0, 0, 0, DateTimeKind.Utc), baseDate); Assert.NotEqual(dt.Day, baseDate.Day); }
public void TestDateTimeConverterFrom() { // ARRANGE DateTime date = DateTime.UtcNow; date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind); TimestampConverter converter = new TimestampConverter(); DynamoDBEntry entry = new Primitive() { Value = date.ToString("o") }; // ACT object data = converter.FromEntry(entry); DateTime derived = ServiceUtilities.ConvertFromUnixTimestamp((long)data); // ASSERT Assert.Equal(date, derived); }