Skip to content

fix(pg): preserve seconds in historical Date timezone offsets - #3799

Open
sueun-dev wants to merge 1 commit into
brianc:masterfrom
sueun-dev:codex/pg-historical-timestamp-offset
Open

sueun-dev wants to merge 1 commit into
brianc:masterfrom
sueun-dev:codex/pg-historical-timestamp-offset

Conversation

@sueun-dev

Copy link
Copy Markdown

Date parameters lose part of their offset when the local timezone used second-level offsets. With TZ=Africa/Monrovia, new Date(0) becomes 1969-12-31T23:15:30.000-00:44, which PostgreSQL reads as -30,000ms instead of 0.

Keep the local date/time fields and append the offset's seconds when present. This covers Date arrays too; the UTC serialization option stays unchanged.

Added unit cases for positive and negative historical offsets, UTC, BC years and input preservation. The PostgreSQL tests exercise both JS and native clients with ISO-string controls and Date arrays, and check the local fields for timestamp and date.

Checked on Linux arm64, Node 24.21.0 and PostgreSQL 15.19:

  • The focused new tests fail before the fix and pass after it.
  • yarn lint and yarn test pass.

The harness skipped pg-worker, SCRAM, two native-pipeline cases and PostgreSQL 17+ direct SSL. pg-pool reports one pending test. Other CI versions and platforms were not run locally.

Prepared with AI assistance.

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