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
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I noticed some difference when a DateTime is parsed from query or body.
See this controller as demo :
When the timezone is unspecified, it's the same result :
When the timezone is specified with "Z" (UTC denominator), it's the same result :
But when the timezone is specified with UTC offset, the result differ :
This difference come from the parsing method.
When DateTime is passed by query, then DateTimeModelBinder use
DateTime.Parse
withDateTimeStyles.AdjustToUniversal
.When DateTime is passed by body, then DateTimeConverter use a custom method specific to System.Text.Json
I know it's possible to defined custom binder/converter, but I think a more homogeneous behavior would be easier to understand for a newbie.
Beta Was this translation helpful? Give feedback.
All reactions