Skip to content

Translate three-argument ConvertTimeBySystemTimeZoneId - #3939

Merged
roji merged 1 commit into
mainfrom
roji-ef-functions-at-time-zone
Oct 12, 2026
Merged

roji merged 1 commit into
mainfrom
roji-ef-functions-at-time-zone

Conversation

@roji

@roji roji commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Allow queries to convert a local timestamp using an explicit source timezone, including timezone IDs stored in columns, via TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dateTime, sourceTimeZoneId, destinationTimeZoneId).

Require the input to be mapped to timestamp without time zone and translate to (value AT TIME ZONE source) AT TIME ZONE destination. Both timezone arguments can be constants, parameters, or columns. The result always maps to timestamp without time zone, even for UTC destinations, consistent with the existing two-argument translation. Callers needing a UTC DateTime/timestamptz result can compose with the existing DateTime.SpecifyKind(..., DateTimeKind.Utc) translation.

Keep the DateTimeOffset overload unsupported because its nonzero-offset result cannot be represented by PostgreSQL. Includes coverage for UTC and non-UTC destinations, parameter and column timezones, UTC result composition, and unsupported inputs.

Fixes #3938

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 74c2225a-4061-4e50-affb-9d87fdf942c7
Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:52
@roji
roji enabled auto-merge (squash) October 12, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the requested semantics and includes comprehensive coverage.

0 open findings

What changed in this PR

Adds translation for three-argument TimeZoneInfo.ConvertTimeBySystemTimeZoneId using nested PostgreSQL AT TIME ZONE operations.

Changes:

  • Supports constant, parameter, and column timezone IDs.
  • Enforces timestamp without time zone inputs and preserves timestamp result mapping.
  • Adds coverage for conversions, UTC composition, and unsupported inputs.
File Description
NpgsqlDateTimeMethodTranslator.cs Implements and validates the new translation.
TimestampTranslationsTest.cs Adds functional and failure-case coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@roji
roji merged commit b09cc6c into main Oct 12, 2026
16 checks passed
@roji
roji deleted the roji-ef-functions-at-time-zone branch October 12, 2026 11:06
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.

Translate the three-argument TimeZoneInfo.ConvertTimeBySystemTimeZoneId overload

2 participants