1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-08 16:36:15 +00:00

Fixed DateTime converter for nanosecond times in string format

This commit is contained in:
Jkorf 2022-01-25 13:01:21 +01:00
parent 2c43ee7554
commit 893d0c723d
2 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,7 @@ namespace CryptoExchange.Net.UnitTests
[TestCase("1620777600.000")] [TestCase("1620777600.000")]
[TestCase("1620777600000")] [TestCase("1620777600000")]
[TestCase("2021-05-12T00:00:00.000Z")] [TestCase("2021-05-12T00:00:00.000Z")]
[TestCase("2021-05-12T00:00:00.000000000Z")]
[TestCase("", true)] [TestCase("", true)]
[TestCase(" ", true)] [TestCase(" ", true)]
public void TestDateTimeConverterString(string input, bool expectNull = false) public void TestDateTimeConverterString(string input, bool expectNull = false)

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -110,7 +111,7 @@ namespace CryptoExchange.Net.Converters
return new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc); return new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc);
} }
return JsonConvert.DeserializeObject(stringValue); return DateTime.Parse(stringValue, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
} }
else if(reader.TokenType == JsonToken.Date) else if(reader.TokenType == JsonToken.Date)
{ {