mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
16 lines
551 B
C#
16 lines
551 B
C#
|
|
using System;
|
||
|
|
using System.Text.Json;
|
||
|
|
using System.Text.Json.Serialization;
|
||
|
|
|
||
|
|
namespace Marechai.Server.Helpers;
|
||
|
|
|
||
|
|
public sealed class IsoDateTimeConverter : JsonConverter<DateTime>
|
||
|
|
{
|
||
|
|
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||
|
|
DateTime.Parse(reader.GetString());
|
||
|
|
|
||
|
|
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||
|
|
{
|
||
|
|
writer.WriteStringValue(value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));
|
||
|
|
}
|
||
|
|
}
|