Fix DeserializeXNode in .net core

This commit is contained in:
wojtpl2
2016-09-09 11:32:15 +02:00
parent fac72ad50c
commit dde688207c
2 changed files with 16 additions and 1 deletions
@@ -1674,7 +1674,7 @@ namespace Newtonsoft.Json.Converters
#if !PORTABLE
return XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind));
#else
return XmlConvert.ToString(d);
return XmlConvert.ToString(d, DateTimeUtils.ToDateTimeFormat(d.Kind));
#endif
}
else if (reader.TokenType == JsonToken.Null)
@@ -73,6 +73,21 @@ namespace Newtonsoft.Json.Utilities
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("kind", kind, "Unexpected DateTimeKind value.");
}
}
#else
public static string ToDateTimeFormat(DateTimeKind kind)
{
switch (kind)
{
case DateTimeKind.Local:
return "yyyy-MM-ddTHH:mm:sszzzzzzz";
case DateTimeKind.Unspecified:
return "s";
case DateTimeKind.Utc:
return "yyyy-MM-ddTHH:mm:ssZ";
default:
throw new Exception("Unexpected DateTimeKind value.");
}
}
#endif
internal static DateTime EnsureDateTime(DateTime value, DateTimeZoneHandling timeZone)