Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Fixing date parsing for VSTS repos #838

Merged
merged 6 commits into from
Jun 22, 2018
Merged

Conversation

StanleyGoldman
Copy link
Contributor

@StanleyGoldman StanleyGoldman commented Jun 19, 2018

Fixes #835

  • Switched to using Constants.Iso8601Formats in SimpleJson.
  • Added a test to verify that LocksOutputProcessor is working as expected.

Update by @shana:

This adds more milisecond precision variants to the ISO8601 formats, given that different servers return different variations of the standard. Because standards.

iso 8601

@@ -1369,9 +1369,9 @@ public virtual object DeserializeObject(object value, Type type)
if (type == typeof(NPath) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(NPath)))
return new NPath(str);
if (type == typeof(DateTime) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime)))
return DateTime.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
return DateTime.ParseExact(str, Constants.Iso8601Formats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have Iso8601Format point to Constants instead of hardcoding that here, it's easier to maintain that way I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

public static readonly string[] Iso8601Formats = {
Iso8601FormatZ,
@"yyyy-MM-dd\THH\:mm\:ss.fffffffzzz",
Iso8601Format,
Iso8601FormatPointZ,
Copy link
Member

Choose a reason for hiding this comment

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

The Iso8601Format and Iso8601FormatZ are the preferred ones, which is why I made them into consts, but we'll need way more. This list probably needs to read more like

        public static readonly string[] Iso8601Formats = {
            Iso8601Format,
            Iso8601FormatZ,
            @"yyyy-MM-dd\THH\:mm\:ss.fffffffzzz",
            @"yyyy-MM-dd\THH\:mm\:ss.ffffffzzz",
            @"yyyy-MM-dd\THH\:mm\:ss.fffffzzz",
            @"yyyy-MM-dd\THH\:mm\:ss.ffffzzz",
            @"yyyy-MM-dd\THH\:mm\:ss.ffzzz",
            @"yyyy-MM-dd\THH\:mm\:ss.fzzz",
            @"yyyy-MM-dd\THH\:mm\:sszzz",
            @"yyyy-MM-dd\THH\:mm\:ss.fffffff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.ffffff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.fffff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.ffff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.fff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.ff\Z",
            @"yyyy-MM-dd\THH\:mm\:ss.f\Z",
        };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@shana shana merged commit 858c0c2 into master Jun 22, 2018
@shana shana deleted the fixes/datetime-format-string branch June 22, 2018 13:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants