diff --git a/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/README.txt b/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/README.txt new file mode 100644 index 0000000000..0b46df9df6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/README.txt @@ -0,0 +1,29 @@ +SimpleJson is from https://github.com/facebook-csharp-sdk/simple-json + +CHANGES MADE +============ +* Better handling of System.DateTime serialized by Json.NET + as suggested in https://github.com/facebook-csharp-sdk/simple-json/issues/78 + +LICENSE (from https://github.com/facebook-csharp-sdk/simple-json/blob/08b6871e8f63e866810d25e7a03c48502c9a234b/LICENSE.txt): +===== +Copyright (c) 2011, The Outercurve Foundation + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/SimpleJson.cs b/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/SimpleJson.cs index b20d8661d0..33fa6088ce 100644 --- a/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/SimpleJson.cs +++ b/src/Microsoft.AspNetCore.Blazor/Json/SimpleJson/SimpleJson.cs @@ -1343,7 +1343,8 @@ namespace SimpleJson if (str.Length != 0) // We know it can't be null now. { 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.TryParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var result) + ? result : DateTime.Parse(str, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind); if (type == typeof(DateTimeOffset) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTimeOffset))) return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))