Skip to content

proposal: time: add RFC 9557 Internet Extended Date/Time Format (IXDTF) support #75320

@8beeeaaat

Description

@8beeeaaat

Proposal Details

This proposal suggests adding support for RFC 9557 Internet Extended Date/Time Format (IXDTF) to Go's time package. IXDTF is a backward-compatible extension of RFC 3339 that adds optional suffix elements for timezone names and metadata.

https://www.rfc-editor.org/rfc/rfc9557.html

Background

RFC 9557, published in 2024, extends RFC 3339 by allowing additional suffix information while maintaining full backward compatibility. This enables more precise time representation for internationalization, calendar systems, and metadata preservation.

Current State

time package has excellent RFC 3339 support with optimized parsing and formatting functions (parseRFC3339, appendFormatRFC3339). However, it cannot handle IXDTF's extended format.

https://github.com/golang/go/blob/master/src/time/format_rfc3339.go

Examples

Basic RFC 3339:
2006-01-02T15:04:05Z
2006-01-02T15:04:05.999999999-07:00

IXDTF with timezone:
2006-01-02T15:04:05Z[UTC]
2006-01-02T15:04:05+09:00[Asia/Tokyo]

IXDTF with extensions:
2006-01-02T15:04:05Z[u-ca=japanese]
2006-01-02T15:04:05+09:00[Asia/Tokyo][u-ca=japanese]

IXDTF with critical extensions:
2006-01-02T15:04:05Z[!u-ca=japanese]

Motivation

  1. Standards Compliance: RFC 9557 is an official IETF standard extending RFC 3339
  2. Internationalization: Better support for non-Gregorian calendars and localization
  3. Interoperability: Compatibility with systems already using IXDTF
  4. Metadata Preservation: Ability to preserve timezone and calendar information in serialization

Proposed API (Initial Concept)

// New constants
const (
    RFC9557TimeZone     = "2006-01-02T15:04:05Z07:00[time-zone]"
    RFC9557NanoTimeZone = "2006-01-02T15:04:05.999999999Z07:00[time-zone]"
)

// Extension information structure
type IXDTFExtensions struct {
    TimeZone  string            // IANA timezone name
    Tags      map[string]string // Extension tags
    Critical  map[string]bool   // Critical flags
}

// New parsing/formatting functions
func (t Time) appendFormatRFC9557(b []byte, nanos bool, ext IXDTFExtensions) []byte
func parseRFC9557[bytes []byte | string](s bytes, local *Location) (Time, IXDTFExtensions, bool)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions