You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JsonSerializer does not support parsing DateTime value '0001-01-01T00:00:00+01:00' #70547
Fundamentally, I think the issue is that 0001-01-01T00:00:00+01:00 is an invalid ISO-8601 date/time string. If I try to parse it using DateTimeOffset.Parse I get the following error:
The UTC representation of the date '0001-01-01T00:00:00+01:00' falls outside the year range 1-9999.
And the same error surfaces if I try to convert you DateTime value to DateTimeOffset. I think the problem lies with the serializer, given that it serializes using ISO-8601 it should simply reject that particular value.
nit: it's a valid date/time string, it's just outside the range supported by DateTime
That aside, if you're attempting to create an invalid date for "not a value"/"not passed" semantics, you should be passing null, or a UTC timestamp, not one with an offset. (That's beside the question of whether you should be using DateTime at all, instead of DateTimeOffset or NodaTime, but that's a more involved analysis)
Reacted by Tarek Mahmoud Sayed and Tim Schneeberger
Activity
eiriktsarpalis commentedon Jun 10, 2022
Fundamentally, I think the issue is that
0001-01-01T00:00:00+01:00is an invalid ISO-8601 date/time string. If I try to parse it usingDateTimeOffset.ParseI get the following error:And the same error surfaces if I try to convert you
DateTimevalue toDateTimeOffset. I think the problem lies with the serializer, given that it serializes using ISO-8601 it should simply reject that particular value.cc @tarekgh
Clockwork-Muse commentedon Jun 10, 2022
nit: it's a valid date/time string, it's just outside the range supported by
DateTimeThat aside, if you're attempting to create an invalid date for "not a value"/"not passed" semantics, you should be passing
null, or a UTC timestamp, not one with an offset. (That's beside the question of whether you should be usingDateTimeat all, instead ofDateTimeOffsetor NodaTime, but that's a more involved analysis)