Converters/MillisecondUnixConverter.cs

A System.Text.Json converter that reads a Unix timestamp in milliseconds and converts it to a DateTime. It implements Read by reading an Int64 and adding that many milliseconds to DateTime.UnixEpoch, Write is not implemented and throws.

Obfuscated Code
#nullable enable annotations

using System.Text.Json;
using System.Text.Json.Serialization;

namespace LichessNET.Converters;

public class MillisecondUnixConverter : JsonConverter<DateTime>
{
    public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var milliseconds = reader.GetInt64();
        DateTime unixEpoch = DateTime.UnixEpoch;
        return unixEpoch.Add(TimeSpan.FromMilliseconds(milliseconds));
    }

    public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
    {
        throw new NotImplementedException();
    }
}