From 0886230ddaf576140b411099946196d0627da11d Mon Sep 17 00:00:00 2001 From: Serraniel Date: Fri, 3 Mar 2023 15:40:25 +0100 Subject: [PATCH] Fixes parsing for datetime in CardPrice JsonConverter --- .../Utils/JsonConverter/CardPriceConverter.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/JpnCardsPokemon.Sdk/Utils/JsonConverter/CardPriceConverter.cs b/JpnCardsPokemon.Sdk/Utils/JsonConverter/CardPriceConverter.cs index e400981..3628814 100644 --- a/JpnCardsPokemon.Sdk/Utils/JsonConverter/CardPriceConverter.cs +++ b/JpnCardsPokemon.Sdk/Utils/JsonConverter/CardPriceConverter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -81,8 +82,9 @@ internal class CardPriceConverter : JsonConverter> value = reader.GetString(); else if (propertyType == typeof(decimal)) value = reader.GetDecimal(); - else if (propertyType == typeof(DateTime)) - if (DateTime.TryParse(reader.GetString(), out var dt)) + else if (propertyType == typeof(DateTime?)) + if (DateTime.TryParseExact(reader.GetString(), "MM/dd/yyyy", + CultureInfo.InvariantCulture, DateTimeStyles.None, out var dt)) value = dt; property.SetValue(cardPrice, value);