Skip to content

feat(vm): Time/Date standard formatters — Time#iso8601/xmlschema/rfc2822/httpdate - #343

Merged
tannevaled merged 2 commits into
mainfrom
feat/time-date-formatters
Aug 9, 2026
Merged

feat(vm): Time/Date standard formatters — Time#iso8601/xmlschema/rfc2822/httpdate#343
tannevaled merged 2 commits into
mainfrom
feat/time-date-formatters

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Horodate: 2026-08-09 22:54 CEST

What

Implements the deferred require "time" instance formatters on Time, built on the VM's existing strftime engine (Date/DateTime already shipped theirs in #340):

  • Time#iso8601(fraction_digits=0) and its alias Time#xmlschema%Y-%m-%dT%H:%M:%S, optional .NNN fractional part (n truncated digits), then Z for a UTC instant or %:z (+HH:MM) for a fixed-offset one.
  • Time#rfc2822 / Time#rfc822%a, %d %b %Y %H:%M:%S %z, where a UTC instant reports RFC 2822's -0000 unknown-local-zone marker (MRI quirk), a fixed offset its +HHMM.
  • Time#httpdate — the instant converted to GMT as %a, %d %b %Y %H:%M:%S GMT.

Every output was verified byte-for-byte against ruby 4.0.5 (ruby -rtime -e …), including the UTC-Z vs +00:00 distinction, the -0000 vs +0000 rfc2822 distinction, fraction-digit variants, and the httpdate GMT reconversion.

Deferred (noted, not implemented)

  • The class-method parsers Time.iso8601 / Time.xmlschema / Time.rfc2822 / Time.httpdate. MRI's are strict (each rejects the other formats with ArgumentError), so they need real format-specific parsers rather than routing through the existing lenient Time.parse (gotime.ParseAny) — out of scope for a clean, 100%-coverable change. Time.parse / Time.strptime are untouched.
  • Time#rfc3339does not exist in MRI (Time.respond_to?(:rfc3339) → false; NoMethodError on instances), so nothing to add. Date/DateTime already have #rfc3339.

Verification

  • New Go table cases in internal/vm/time_test.go asserting literal MRI outputs on fixed deterministic instants (UTC + +02:00 + +00:00, fraction variants). go test ./internal/vm -run TestTime green.
  • Full GOWORK=off go test ./... — exit 0, no regressions.
  • CI-exact whole-package coverage gate (grep -vE '100.0%' minus the tolerated pre-existing partials) — empty; iso8601Str / rfc2822Str / httpdateStr each 100.0%.
  • gofmt + go vet ./internal/vm/ clean (pre-existing builtins.go delta untouched).
  • ruby/spec ratchet: 12381 passing (files loaded 2103), ≥ FLOOR; FLOOR bumped 12346 → 12351 (N−30).

🤖 Generated with Claude Code

tannevaled and others added 2 commits August 9, 2026 22:39
Horodate: 2026-08-09 22:47 CEST

WIP: adds the require "time" instance formatters to Time, built on the
existing strftime engine (Date/DateTime already carried theirs via #340).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Horodate: 2026-08-09 22:53 CEST

Time standard formatters lift passing to 12381; lock in at N-30.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit de4ee8f into main Aug 9, 2026
5 of 7 checks passed
@tannevaled
tannevaled deleted the feat/time-date-formatters branch August 9, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant