cqframework / cqframework/cql-tests

Wrong Expected Output on Date Subtraction with Partial Dates

Open
#72 4 comments 0 reactions 1 assignee View on GitHub

@raleigh-g-thompson is already working on this.

Since Oct 1, 2025.

bug CQLTest: CQL-Spec-Change CQLTest: CQL-test-code
Dominant language
No language data
Stars
7
Forks
8
Avg merge
12d 5h
Merged PRs (30d)
2

Description

The test specifies the following CQL:

DateTime(2016,5) - 31535999 seconds = DateTime(2015, 5)

and expected outcome true.

This is tricky because the CQL spec says:

For partial date/time values where the time-valued quantity is more precise than the partial date/time, the operation is performed by converting the time-based quantity to the most precise value specified in the first argument (truncating any resulting decimal portion) and then subtracting it from the first argument.

It's not clear how to convert seconds into months. If we convert 31535999 seconds to months using UCUM units, we get 11.991786. If we then truncate the decimal portion (as the spec suggests) and subtract, we end up with DateTime(2015, 6), not DateTime(2015, 5). Translating seconds to days still comes in at 364.99999, which is less than a year, and therefore less than 12 months (landing on DateTime(2015, 6)).

So... although DateTime(2016,5) - 31535999 seconds is almost DateTime(2015, 5), it's not quite that. It would probably be best to either increase the seconds to 31557600 or fix the test to expect DateTime(2015,6). (Or tell me how engines should be doing this calculation to arrive at DateTime(2015, 5)).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.