Skip to content

Implement [ZN] timezone name modifier for format-dateTime#6092

Open
joewiz wants to merge 1 commit intoeXist-db:developfrom
joewiz:feature/zn-timezone-modifier
Open

Implement [ZN] timezone name modifier for format-dateTime#6092
joewiz wants to merge 1 commit intoeXist-db:developfrom
joewiz:feature/zn-timezone-modifier

Conversation

@joewiz
Copy link
Member

@joewiz joewiz commented Mar 3, 2026

Summary

  • Implement the [ZN] presentation modifier for the Z timezone component in format-dateTime / format-date / format-time, per the W3C XPath Functions 3.1 spec (section 9.8.4.7)
  • When $place is a recognized IANA timezone name (e.g., America/New_York), adjust the datetime to the applicable timezone offset before formatting, taking daylight savings time into account — this affects all components (H, M, Z, etc.), per the spec: "the date or time being formatted is adjusted to the timezone offset applicable in that timezone"
  • Resolve timezone abbreviations via java.time.DateTimeFormatter, with fallbacks for CLDR gaps (e.g., IST for +05:30) and a final numeric fallback (e.g., +13:00)
  • Support [Zn] (lowercase) and [ZNn] (title case) variants
  • Remove 11 %test:pending annotations and fix incorrect test expectations

The $place timezone adjustment approach is similar to the one used by BaseX (BSD 3-Clause license).

Closes #1024

Test plan

  • eXist-db format-dates.xql test suite: 121/121 pass (0 failures)
  • W3C XQTS fn-format-dateTime: 53/78 pass (25 pre-existing failures unrelated to [ZN])
  • W3C XQTS fn-format-date: 52/95 pass (43 pre-existing failures)
  • W3C XQTS fn-format-time: 25/37 pass (12 pre-existing failures)

🤖 Generated with Claude Code

@joewiz joewiz changed the base branch from master to develop March 3, 2026 18:24
@joewiz joewiz requested a review from a team as a code owner March 3, 2026 18:24
Implement the [ZN] presentation modifier for the Z timezone component in
format-dateTime, format-date, and format-time, per the W3C XPath Functions
3.1 spec (section 9.8.4.7).

Changes to FnFormatDates.java:

- When $place is a recognized IANA timezone name (e.g., "America/New_York"),
  adjust the datetime to the applicable timezone offset before formatting,
  taking daylight savings time into account. This affects all components
  (H, M, Z, etc.), not just the timezone display.

- Implement formatTimeZoneName() for the [ZN] modifier: uses java.time
  DateTimeFormatter to resolve timezone abbreviations (e.g., "EST", "EDT"),
  with a generic offset-based lookup preferring shorter abbreviations
  (e.g., "HST" over "HAST"), a fallback to well-known legacy abbreviation
  IDs (e.g., "IST" for +05:30 which CLDR doesn't abbreviate), and a final
  numeric fallback (e.g., "+13:00").

- Support [Zn] (lowercase) and [ZNn] (title case) variants.

Changes to format-dates.xql:

- Remove 11 %test:pending annotations for [ZN] tests.

- Fix incorrect test expectations for $place="America/New_York" tests:
  the original tests had wrong time values (place only affects Z component)
  and wrong timezone names (EST instead of EDT for June dates). Corrected
  to show datetime adjusted to NY timezone with EDT.

The $place timezone adjustment approach is similar to the one used by
BaseX (BSD 3-Clause license).

Closes eXist-db#1024

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joewiz joewiz force-pushed the feature/zn-timezone-modifier branch from d6f7075 to 46a9735 Compare March 5, 2026 01:40
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.

Presentation modifiers for Z datetime formatting picture string not supported

2 participants