Skip to content

Keep the fractional part of the execution timezone offset when defaulting a DateTime's offset - #396

Merged
dehall merged 1 commit into
cqframework:masterfrom
bryantaustin13:datetime-fractional-default-offset
Nov 2, 2026
Merged

dehall merged 1 commit into
cqframework:masterfrom
bryantaustin13:datetime-fractional-default-offset

Conversation

@bryantaustin13

@bryantaustin13 bryantaustin13 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #395

When a DateTime literal or the DateTime(...) selector had no timezone offset, DateTime.exec filled in the execution offset as an Integer literal. IntegerLiteral runs parseInt, so a +05:30 execution offset became +05:00, and -09:30 became -09:00. Now() and ToDateTime(String) kept the full offset, so for example @2014-01-01T12:05 = ToDateTime('2014-01-01T12:05') returned false at +05:30.

CQL 1.5.3, Logical Specification, DateTime:

If timezoneOffset is not specified, it is defaulted to the timezone offset of the evaluation request.

The timezoneOffset operand is a Decimal.

Changes

  • src/elm/datetime.ts: build the default offset as a Decimal literal (ELM_DECIMAL_TYPE) instead of an Integer literal.
  • test/elm/datetime/datetime-test.ts: two tests that run the existing minute-precision DateTime expression with execution offsets of +5.5 and -9.5, and check that the result keeps the full offset.

Verification

  • The two new tests fail without the src/ change (expected '5.0' to equal Decimal '5.5') and pass with it.
  • npm run check passes: build, test data generation, test:typecheck, test, lint and prettier. npm test goes from 5450 passing / 99 pending on master (e8096c6) to 5452 passing / 99 pending / 0 failing.
  • With test-server evaluating at +05:30, offset-less literals and DateTime(...) results now get +05:30, the same offset as Now() and ToDateTime(String). The 23 tests in the reworked CQLTimeZoneOffsetTest.xml (added tests for timezone offset tests cql-tests#88) all pass at +05:30 with this change. Without it, three fail.

Submitter:

  • This pull request describes why these changes were made
  • Code diff has been done and been reviewed (it does not contain: additional white space, not applicable code changes, debug statements, etc.)
  • Tests are included and test edge cases
  • Tests have been run locally and pass
  • Code coverage has not gone down and all code touched or added is covered.
  • Code passes lint and prettier (hint: use npm run check to run tests, lint, and prettier)
  • All dependent libraries are appropriately updated or have a corresponding PR related to this change (N/A)

Reviewer:

Name:

  • Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task's purpose
  • The tests appropriately test the new code, including edge cases
  • You have tried to break the code

🤖 Generated with Claude Code

@bryantaustin13
bryantaustin13 marked this pull request as draft October 26, 2026 20:49
@codecov-commenter

codecov-commenter commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.17%. Comparing base (b0d3217) to head (acf0378).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #396   +/-   ##
=======================================
  Coverage   89.17%   89.17%           
=======================================
  Files          60       60           
  Lines        5080     5080           
  Branches     1453     1453           
=======================================
  Hits         4530     4530           
  Misses        317      317           
  Partials      233      233           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bryantaustin13 bryantaustin13 changed the title Keep the fractional execution timezone offset when defaulting a DateT… Keep the fractional part of the execution timezone offset when defaulting a DateTime's offset Oct 26, 2026
@bryantaustin13
bryantaustin13 marked this pull request as ready for review October 26, 2026 20:56

@dehall dehall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the pull request, this looks good to me

…ime's offset

DateTime.exec filled in a missing timezoneOffset with an Integer literal,
and IntegerLiteral's parseInt dropped the fraction: a +05:30 execution
offset became +05:00. Use a Decimal literal so offset-less DateTime
literals and selectors get the same offset as Now() and ToDateTime(String).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dehall
dehall force-pushed the datetime-fractional-default-offset branch from c9f9ae4 to acf0378 Compare November 2, 2026 16:48
@dehall
dehall merged commit 66a2e50 into cqframework:master Nov 2, 2026
7 checks passed
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.

Offset-less DateTime literals and DateTime(...) drop the fractional part of the execution timezone offset

3 participants