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
DateOnly is serialized to JSON as 'yyyy-MM-dd' (e.g. '2022-01-16').
When it's deserialized (in JS), NJsonSchema uses new Date('2022-01-16').
Considering I'm in New York (UTC -5), new Date('2022-01-16').toLocaleString() gives me 1/15/2022, 7:00:00 PM, and new Date('2022-01-16').toLocaleDateString() gives 1/15/2022.
Moreover, if I now send this received DateOnly back to my API, it'd be sent as 2022-01-15, because formatDate (used in NJsonSchema for DateOnly serialization) uses local date.
My personal expectation was to get it deserialized as 1/16/2022, 12:00:00 AM (regardless of my time zone).
I understand, that JS by default interprets 'yyyy-MM-dd' as UTC date, but imo it'd be correct to adjust DateOnly fields after deserialization (or at least to make it configurable/provide some callbacks that I could set to adjust deserialization for DateOnly fields)
The text was updated successfully, but these errors were encountered:
I could PR that if you are ok with the idea and could help me with name for setting (in TypeScriptGeneratorSettings), that will enable that behavior :)
DateOnly is serialized to JSON as 'yyyy-MM-dd' (e.g. '2022-01-16').
When it's deserialized (in JS), NJsonSchema uses
new Date('2022-01-16')
.Considering I'm in New York (UTC -5),
new Date('2022-01-16').toLocaleString()
gives me1/15/2022, 7:00:00 PM
, andnew Date('2022-01-16').toLocaleDateString()
gives1/15/2022
.Moreover, if I now send this received DateOnly back to my API, it'd be sent as
2022-01-15
, becauseformatDate
(used in NJsonSchema forDateOnly
serialization) uses local date.My personal expectation was to get it deserialized as
1/16/2022, 12:00:00 AM
(regardless of my time zone).I understand, that JS by default interprets 'yyyy-MM-dd' as UTC date, but imo it'd be correct to adjust
DateOnly
fields after deserialization (or at least to make it configurable/provide some callbacks that I could set to adjust deserialization for DateOnly fields)The text was updated successfully, but these errors were encountered: