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

@@ -118,7 +118,7 @@ namespace DiscordChatExporter.Core.Services
var title = json["title"]?.Value<string>();
var description = json["description"]?.Value<string>();
var url = json["url"]?.Value<string>();
var timestamp = json["timestamp"]?.Value<DateTimeOffset>();
var timestamp = json["timestamp"]?.Value<DateTime>().ToDateTimeOffset();
// Get color
var color = json["color"] != null
@@ -165,8 +165,8 @@ namespace DiscordChatExporter.Core.Services
// Get basic data
var id = json["id"].Value<string>();
var channelId = json["channel_id"].Value<string>();
var timestamp = json["timestamp"].Value<DateTimeOffset>();
var editedTimestamp = json["edited_timestamp"]?.Value<DateTimeOffset?>();
var timestamp = json["timestamp"].Value<DateTime>().ToDateTimeOffset();
var editedTimestamp = json["edited_timestamp"]?.Value<DateTime?>()?.ToDateTimeOffset();
var content = json["content"].Value<string>();
var type = (MessageType) json["type"].Value<int>();