public override void Write(Utf8JsonWriter writer, TMessage value, JsonSerializerOptions options)
    {
        int  nanos;
        long seconds;

        if (value is Timestamp timestamp)
        {
            nanos   = timestamp.Nanos;
            seconds = timestamp.Seconds;
        }
        else
        {
            nanos   = (int)value.Descriptor.Fields[Timestamp.NanosFieldNumber].Accessor.GetValue(value);
            seconds = (long)value.Descriptor.Fields[Timestamp.SecondsFieldNumber].Accessor.GetValue(value);
        }

        var text = Legacy.GetTimestampText(nanos, seconds);

        writer.WriteStringValue(text);
    }