Skip to content

Do not use IsoDateTimeConverter to handle DateTimeOffset #2263

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

Merged
merged 1 commit into from
Sep 20, 2016

Conversation

russcam
Copy link
Contributor

@russcam russcam commented Sep 15, 2016

IsoDateTimeConverter deserializes a DateTimeOffset represented according ISO8601 into a DateTimeOffset with a local offset. For example "1999-01-01T01:01:01.001+05:00" deserializes to a DateTimeOffset with a value of 01/01/1999 07:01:01 +11:00. The +11 offset is my local offset (Australia). The default deserialization for a DateTimeOffset not using IsoDateTimeConverter deserializes into a DateTimeOffset with an offset that reflects the one in the ISO8601 string representation.

This seems more appropriate behaviour.

Use CultureInfo.InvariantCulture in IsoDateTimeConverter when deserializing DateTime

IsoDateTimeConverter deserializes a DateTimeOffset represented in an ISO8601 into a DateTimeOffset with a local offset. For example "1999-01-01T01:01:01.001+05:00" deserializes to a DateTimeOffset with a value of 01/01/1999 07:01:01 +11:00. The +11 offset is my local offset (Australia). The default deserialization for a DateTimeOffset not using IsoDateTimeConverter deserializes into a DateTimeOffset with an offset that reflects the one in the ISO8601 string representation. This seems more appropriate behaviour.

Use InvariantCulture in the IsoDateTimeConverter when deserializing DateTime
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The DateTimeOffset deserialization was a regression from 1.x which behaved correctly here.

@russcam
Copy link
Contributor Author

russcam commented Sep 16, 2016

Here's the related Json.NET issue: JamesNK/Newtonsoft.Json#159

@russcam russcam merged commit b8ffbbf into 2.x Sep 20, 2016
@russcam russcam added the v2.4.6 label Sep 23, 2016
@Mpdreamz Mpdreamz deleted the fix/2.x-datetimeoffset-deserialization branch November 30, 2016 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants