Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for default timezone offset of DateTime #1423

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

antvaset
Copy link
Contributor

@antvaset antvaset commented Oct 8, 2024

Closes #1420.

This PR adds tests for calling DateTime(y, m, d, h, m, s, ms) without specifying the timezone offset. As per the spec, it should default to the timezone offset of the evaluation request.

Note that when engine.expression(...) or engine.evaluate(...) is called without passing in the evaluation date time explicitly, it is set to ZonedDateTime.now().

Copy link

github-actions bot commented Oct 8, 2024

Formatting check succeeded!

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.39%. Comparing base (a7c1636) to head (fa3ef71).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1423   +/-   ##
=========================================
  Coverage     64.38%   64.39%           
+ Complexity     1921     1920    -1     
=========================================
  Files           494      494           
  Lines         28020    28020           
  Branches       5559     5559           
=========================================
+ Hits          18042    18044    +2     
  Misses         7737     7737           
+ Partials       2241     2239    -2     

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

Copy link
Member

@brynrhodes brynrhodes left a comment

Choose a reason for hiding this comment

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

This is only the test, but doesn't the DateTimeEvaluator need to be updated as well?

@JPercival
Copy link
Contributor

I walked through the code with Anton. The code looks correct to me. I think I was wrong before, the DateTimeEvaluator is using the timezone of the evaluation request.

@brynrhodes
Copy link
Member

Hmm.... I walked through this the other day and it wasn't, just did again and I don't see how it is using the evaluation request timestamp:

https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/DateTimeEvaluator.java#L33

@JPercival
Copy link
Contributor

The only place that's used is here:
https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/execution/EvaluationVisitor.java#L785-L786

Either the ELM has the offset embedded, or the current offset from the State object is used. That state is set up as part of the evaluation.

Copy link

sonarcloud bot commented Oct 15, 2024

@brynrhodes
Copy link
Member

I see, I was assuming the evaluator tree was still controlling the visit, but I see that it's the visitor now.

@JPercival JPercival merged commit 35668e9 into master Oct 18, 2024
6 checks passed
@JPercival JPercival deleted the add-timezone-offset-test branch October 18, 2024 17:15
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.

DateTime function should use time zone of the evaluation request
3 participants