Add time.Time and Duration encoding/decoding support

Summary

Add first-class support for encoding and decoding time-related types.

Background

Go's json v2 provides comprehensive time handling with multiple format options.

Proposed API

const TimeFormat = enum {
    rfc3339,           // "2006-01-02T15:04:05Z07:00"
    rfc3339_nano,      // With nanoseconds
    unix_seconds,      // 1234567890
    unix_milli,        // 1234567890123
    unix_micro,        // 1234567890123456
    unix_nano,         // 1234567890123456789
    date_only,         // "2006-01-02"
    time_only,         // "15:04:05"
    custom,            // User-defined format
};

const DurationFormat = enum {
    seconds,           // 3600
    milliseconds,      // 3600000
    microseconds,
    nanoseconds,       
    iso8601,           // "PT1H"
    units,             // "1h30m"
};

// Usage in encode options
const options = EncodeOptions{
    .time_format = .rfc3339,
    .duration_format = .seconds,
};

// Or per-field via config
const Event = struct {
    created_at: std.time.Instant,
    duration: i64,
    
    pub const json_config = .{
        .created_at = .{ .format = .unix_milli },
        .duration = .{ .format = .{ .duration = .seconds } },
    };
};

Types to Support

  • std.time.Instant
  • i64 / i128 timestamps
  • Duration as i64 nanoseconds
  • Custom timestamp wrapper types

Format Options

  • RFC 3339 (default)
  • RFC 3339 with nanoseconds
  • Unix timestamps (sec/milli/micro/nano)
  • ISO 8601 duration
  • Custom format strings

Reference

Go: time.Time with format tags like format:unix, format:unixmilli

Priority

High - Common requirement for APIs