Skip to content

fix(pgtype): preserve timestamptz instants with second-level UTC offsets - #2729

Open
Twiink wants to merge 1 commit into
jackc:masterfrom
Twiink:fix/timestamptz-second-precision-offsets
Open

Twiink wants to merge 1 commit into
jackc:masterfrom
Twiink:fix/timestamptz-second-precision-offsets

Conversation

@Twiink

@Twiink Twiink commented Nov 23, 2026

Copy link
Copy Markdown

Behavior

A finite Timestamptz can contain a time with a historical UTC offset that includes seconds. RFC 3339 has minute precision for offsets, so formatting noon in Paris with its historical +00:09:21 offset emits noon at +00:09. Parsing the JSON shifts the instant by 21 seconds.

Convert to UTC when the original offset includes seconds. Offsets that RFC 3339 can represent keep their existing formatting. The regression checks that JSON encoding and decoding preserve the instant.

Verification

  • The new regression failed on master with the original JSON encoder.
  • go test -count=1 -race ./... passed against PostgreSQL 18. Optional tests requiring separate authentication setups or PgBouncer were not enabled.
  • go vet ./... and git diff --check passed.

Codex authored and verified this patch. Prompt summary: reproduce an open-source bug against the upstream default branch, make a focused fix, and run the relevant tests.

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