I have found that the deserialization of iso8601 UTC dates is not done right when fractions of seconds with less than 3 digits of precision are coming.
static void Main(string[] args)
{
using (JsConfig.CreateScope("AssumeUtc:false,AlwaysUseUtc:true,SkipDateTimeConversion:true"))
{
var dt3Dec = JsonSerializer.DeserializeFromString<DateTime>("2020-08-07T09:36:20.960Z");
var dt2Dec = JsonSerializer.DeserializeFromString<DateTime>("2020-08-07T09:36:20.96Z");
var dt1Dec = JsonSerializer.DeserializeFromString<DateTime>("2020-08-07T09:36:20.9Z");
var dtNoDec = JsonSerializer.DeserializeFromString<DateTime>("2020-08-07T09:36:20Z");
Console.WriteLine(TimeZoneInfo.Local.ToString());
Console.WriteLine("3 dec: " + dt3Dec.ToString());
Console.WriteLine("2 dec: " + dt2Dec.ToString());
Console.WriteLine("1 dec: " + dt1Dec.ToString());
Console.WriteLine("0 dec: " + dtNoDec.ToString());
}
}
Result:
(UTC+01:00) Brussels, Copenhagen, Madrid, Paris
3 dec: 07/08/2020 09:36:20
2 dec: 07/08/2020 11:36:20
1 dec: 07/08/2020 11:36:20
0 dec: 07/08/2020 09:36:20
Until de fix arives (if is really a bug), How can i overwrite the DeSerializeFn only inside a Scope and not to affect the deserializations outside the scope?