Skip to content

Fix LocalDateTime.InZoneLeniently member translations - #4170

Open
akayburkay wants to merge 1 commit into
npgsql:mainfrom
akayburkay:fix/4145-nodatime-inzone-leniently
Open

akayburkay wants to merge 1 commit into
npgsql:mainfrom
akayburkay:fix/4145-nodatime-inzone-leniently

Conversation

@akayburkay

Copy link
Copy Markdown

Fixes #4145.

When accessing local members of LocalDateTime.InZoneLeniently(), the existing translation produces a timestamptz value while treating it as a timestamp, causing incorrect results depending on the PostgreSQL session time zone.

This fix converts the local timestamp to an instant and back to local time in the requested time zone. It also handles skipped local times during DST transitions while preserving the existing Instant.InZone() translation.

Added regression tests covering:

  • Hour, Date, and LocalDateTime members.
  • Constant, parameter, and column-based time zones.
  • Different session time zones.
  • Normal, skipped, and ambiguous local times.
  • Generated SQL assertions.

All 363 NodaTime functional tests pass, including 108 new regression cases.

This branch has not been deployed

No deployments
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.

NodaTime: date parts of LocalDateTime.InZoneLeniently(zone) are read in the session time zone, not in zone

1 participant