Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ae278b8

Browse files
committed
Add tests for Date's without times
1 parent 846c8d0 commit ae278b8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/ServiceStack.Text.Tests/JsonTests/JsonDateTimeTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,5 +660,22 @@ public void Does_deserialize_Local_dates_as_UTC()
660660
Assert.AreEqual(DateTimeKind.Utc, deserializedDate.Kind);
661661
Assert.AreEqual(expected, deserializedDate);
662662
}
663+
664+
[Test]
665+
public void Does_serialize_Dates_without_time_as_Local()
666+
{
667+
var date = "2000-01-01".FromJson<DateTime>();
668+
Assert.That(date.Kind, Is.EqualTo(DateTimeKind.Local));
669+
Assert.That(date.ToString("yyyy-MM-dd"), Is.EqualTo("2000-01-01"));
670+
}
671+
672+
[Test]
673+
public void Does_serialize_Dates_without_time_as_UTC_when_UseUtc()
674+
{
675+
JsConfig.AlwaysUseUtc = true;
676+
var date = "2000-01-01".FromJson<DateTime>();
677+
Assert.That(date.Kind, Is.EqualTo(DateTimeKind.Utc));
678+
Assert.That(date.ToString("yyyy-MM-dd"), Is.EqualTo("2000-01-01"));
679+
}
663680
}
664681
}

0 commit comments

Comments
 (0)