DateTimeOffset is handled unexpectedly in frontend
Description
We're transmitting a JSON object to the client which contains a DateTimeOffset field. When this field has the value 0001-01-01T00:00:00+00:00, the call fails.
Repro code
https://fable.io/repl/#?code=PYBwpgdgBAygngZwC5gLYFgBQWkCc5ZRFQi4CWESAZtAEQBKYCArgDZIBcUApAIK1QAFABEAhigAqZVGADyVKgjBIAdAAVRuJYNoAGfQEYAtLuOmJ+jpf0Bqa7toBKR1gDuZJAAsoYAB7QjAD5CYlIKajoAMVEyVjAAEyh3Lx4EAT8IFQBZJgRRAHMwIA&html=DwCwLgtgNgfAsAKAAQqaApgQwCb2ag4CdMTJcMABwFp0BHAVwEsA3AXgCIBhAewDsw6AdQAqAT0roOSAMb9BAzoIAeYAPThoAbhkhMAJwDOJNgzAAzagA4OeQhqy5EhAEY9sYu6mBq3HvD6asEA&css=Q
Expected and actual results
Expected a that a DateTimeOffset is created like in .Net:
> DateTimeOffset.Parse("0001-01-01T00:00:00+00:00");;
val it : DateTimeOffset =
01.01.0001 00:00:00 +00:00 {Date = 01.01.0001 00:00:00;
DateTime = 01.01.0001 00:00:00;
Day = 1;
DayOfWeek = Monday;
DayOfYear = 1;
Hour = 0;
LocalDateTime = 01.01.0001 01:00:00;
Millisecond = 0;
Minute = 0;
Month = 1;
Offset = 00:00:00;
Second = 0;
Ticks = 0L;
TimeOfDay = 00:00:00;
UtcDateTime = 01.01.0001 00:00:00;
UtcTicks = 0L;
Year = 1;}
Actual: Offset must be specified in whole minutes. which is completely misleading IMO.
Related information
- Fable version:
dotnet fable --version3.6.3 - Operating system Windows
I see Result: 0001-01-01 01:12:00 +01:12 in the REPL (I'm GMT+1, so this looks correct, even though JS adds what might be 12 leap minutes, while .NET does not).
The result above is from Firefox. In Chrome I see: Result: 0001-01-01 01:05:00 +01:05. Also not what I would expect... I'm in CET.
I believe we're facing the same error on firefox
We're trying to use DateTimeOffset.MinValue and getting this error
Error: Failed to parse supposedly JSON-encoded URL part Raw(`["QueryPage",{"Query":{"Query":["Indexed",["And",["EqualToString",["Profile",["ProfileId","0edd17ad-7af3-431d-8ec8-49da39637431"]]],["And",["GreaterThanOrEqualToNumeric",["IssuedOn","0001-01-01T00:00:00.000+00:00"]],["LessThanOrEqualToNumeric",["IssuedOn","9999-12-31T23:59:59.999+00:00"]]]]],"OrderBy":["NumericIndexEntry",["UnionCase_",1,"IssuedOn"],"Descending"]},"PageSize":["PositiveInteger",10],"PageNumber":["PositiveInteger",1],"Order":"Ascending"}]`) UrlDecoded(`["QueryPage",{"Query":{"Query":["Indexed",["And",["EqualToString",["Profile",["ProfileId","0edd17ad-7af3-431d-8ec8-49da39637431"]]],["And",["GreaterThanOrEqualToNumeric",["IssuedOn","0001-01-01T00:00:00.000+00:00"]],["LessThanOrEqualToNumeric",["IssuedOn","9999-12-31T23:59:59.999+00:00"]]]]],"OrderBy":["NumericIndexEntry",["UnionCase_",1,"IssuedOn"],"Descending"]},"PageSize":["PositiveInteger",10],"PageNumber":["PositiveInteger",1],"Order":"Ascending"}]`) at index 1, error was Error at: `$.Query.Query`
Expecting a datetimeoffset but instead got: "0001-01-01T00:00:00.000+00:00"