Convert from DateTime to DateTimeOffset instead of parsing it directly

Json.NET is really not meant to be used with DateTimeOffset it seems

Fixes #179
This commit is contained in:
Alexey Golub
2019-06-06 23:31:40 +03:00
parent 2ed374ee5c
commit 9a383d2bd4
3 changed files with 8 additions and 15 deletions

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -9,7 +8,6 @@ using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services.Exceptions;
using DiscordChatExporter.Core.Services.Internal;
using Failsafe;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Tyrrrz.Extensions;
@@ -66,12 +64,7 @@ namespace DiscordChatExporter.Core.Services
var raw = await response.Content.ReadAsStringAsync();
// Parse
using (var reader = new JsonTextReader(new StringReader(raw)))
{
reader.DateParseHandling = DateParseHandling.DateTimeOffset;
return JToken.Load(reader);
}
return JToken.Parse(raw);
}
}
});