Skip to content

Instantly share code, notes, and snippets.

@lukespragg
Forked from jamesantrobus/JsonConvert.cs
Created November 26, 2017 04:42
Show Gist options
  • Save lukespragg/26bfa14b628e614733e03d4eaa730737 to your computer and use it in GitHub Desktop.
Save lukespragg/26bfa14b628e614733e03d4eaa730737 to your computer and use it in GitHub Desktop.
Workaround for Newtonsoft.Json issue 5 https://github.com/chrisntr/Newtonsoft.Json/issues#issue/5
GetUtcOffSet - JsonConvert.cs Line 111
private static TimeSpan GetUtcOffset(DateTime dateTime)
{
#if SILVERLIGHT
return TimeZoneInfo.Local.GetUtcOffset(dateTime);
#else
return TimeZone.CurrentTimeZone.GetUtcOffset(dateTime);
#endif
}
Replacing with this fixes the issue
private static TimeSpan GetUtcOffset(DateTime dateTime)
{
return TimeZone.CurrentTimeZone.GetUtcOffset(dateTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment