-
-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1480. Convert DateOnly properties to local timezone #1481
Conversation
src/NJsonSchema.CodeGeneration.TypeScript/Templates/ConvertToClass.liquid
Outdated
Show resolved
Hide resolved
If this PR should still be merged, please fix the conflicts and we'll have a look at it. |
# Conflicts: # src/NJsonSchema.CodeGeneration.TypeScript/TypeScriptGeneratorSettings.cs
conflicts are fixed |
Thanks for the PR. |
I think this PR doesn't completely fix the issue of dates and timezones, because serialization always assumes a local timezone. Thus, if the setting ConvertDateToLocalTimezone is false, the parsing code will use new Date("2023-09-21") which assumes UTC but the formatting code calls formatDate (https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema.CodeGeneration.TypeScript/Templates/File.FormatDate.liquid) which uses This means if ConvertDateToLocalTimezone is false, you can parse and then immediately convert back to JSON and get a different result. There should also be a Then, when ConvertDateToLocalTimezone is false, the generated Then, both the serialization and deserialization will both use the same expected format and you can serialize followed by a deserialize without changing the data. |
Fixes #1480