using System.Diagnostics; using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; namespace LocalSaveModScoreMigrator; public class DateTimeConverter : JsonConverter { public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { Debug.Assert(typeToConvert == typeof(DateTime)); var dateTime = DateTime.ParseExact(reader.GetString() ?? string.Empty, "dd_MM_yy-HH_mm_ss", CultureInfo.InvariantCulture); return dateTime; } public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) { writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); } }