Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Fixed JsonDeserializer for new Date format (two unit tests were broken). #763

Merged
merged 1 commit into from
Sep 26, 2012
Merged

Fixed JsonDeserializer for new Date format (two unit tests were broken). #763

merged 1 commit into from
Sep 26, 2012

Conversation

dot-i
Copy link
Contributor

@dot-i dot-i commented Sep 25, 2012

No description provided.

@@ -539,7 +539,7 @@ bool ParseBuffer (out object result)

case JsonType.STRING:
if (s.StartsWith("/Date(", StringComparison.Ordinal) && s.EndsWith(")/", StringComparison.Ordinal)) {
int tzCharIndex = s.IndexOfAny(new char[] { '+', '-' });
int tzCharIndex = s.IndexOfAny(new char[] { '+', '-' }, 7);
Copy link
Member

Choose a reason for hiding this comment

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

Why not use LastIndexOfAny()? If it because if you had a date without timezone information "/Date(-59011459200000)/" then it would incorrectly pick up the minus at the beginning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not do it like that because if there is NO timezone it also has to work, and there might be only a negative milliseconds value. So it would again find that minus sign at the beginning of the string. Like this it won't find anything in that case, and that's what we want :-)

thecodejunkie added a commit that referenced this pull request Sep 26, 2012
Fixed JsonDeserializer for new Date format (two unit tests were broken).
@thecodejunkie thecodejunkie merged commit d13062b into NancyFx:master Sep 26, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants