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

Fix DateTime initialization to always use offset from State and never from null #1269

Merged
merged 29 commits into from
Nov 28, 2023

Conversation

lukedegruchy
Copy link
Contributor

@lukedegruchy lukedegruchy commented Nov 1, 2023

  • Ensure that no DateTime constructor accepts a null offset of any kind
  • If no explicit offset is provided, obtain one from the State evaluation time
  • Remove all logic that considered null offsets
  • Never consider timezones or ZoneIds: The requirement is to always use the same offset even across DST changes
  • Fix and/or enhance tests to mix up timezones/offsets and evaluation/now timestamps
  • Hack: Always pass ISO formatted timestamp Strings with offsets to DateTimeType so as to sidestep any default timezone logic when converting DateTimes
  • Explicitly test the CQL expressions in the linked ticket

Closes #863

@lukedegruchy lukedegruchy changed the title First commit. DateTime Interval fix Nov 10, 2023
…tead rely on either the default offsetdatetime.
…tate whenever possible. Fix most units with non-null offsets. There are still test failures to investigate. Lots of cleanup needs to be done afterward.
@lukedegruchy lukedegruchy changed the title DateTime Interval fix Fix DateTime initialization to always use offset from State and never from null Nov 16, 2023
@lukedegruchy lukedegruchy marked this pull request as ready for review November 16, 2023 19:33
Copy link

codecov bot commented Nov 19, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (2985f47) 0.00% compared to head (bc218b2) 61.36%.

❗ Current head bc218b2 differs from pull request most recent head f2ef8fa. Consider uploading reports for the commit f2ef8fa to get more accurate results

Files Patch % Lines
...a/org/opencds/cqf/cql/engine/runtime/DateTime.java 45.45% 12 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #1269       +/-   ##
=============================================
+ Coverage          0   61.36%   +61.36%     
- Complexity        0     6145     +6145     
=============================================
  Files             0      469      +469     
  Lines             0    23651    +23651     
  Branches          0     4566     +4566     
=============================================
+ Hits              0    14514    +14514     
- Misses            0     7028     +7028     
- Partials          0     2109     +2109     

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

Copy link
Contributor

@JPercival JPercival left a comment

Choose a reason for hiding this comment

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

approved, contingent upon adding a few test cases to get up to 80% coverage for DateTime. I'm working on that.

Copy link
Contributor

@c-schuler c-schuler left a comment

Choose a reason for hiding this comment

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

Nice work. I have a couple of notes, but am willing to approve. I would like to see the fromJavaDate function restored unless there is a good reason for its removal.

import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;
import java.time.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting the use of wildcard imports here, which is not best practice.

@@ -296,10 +294,8 @@ public Date toJavaDate() {
return java.util.Date.from(dateTime.toInstant());
}

public static DateTime fromJavaDate(Date date) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very useful function that is used in other projects. I would like to know why it has been removed.

Copy link
Contributor Author

@lukedegruchy lukedegruchy Nov 28, 2023

Choose a reason for hiding this comment

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

The IDE said it was unused and it's my instinct to clean up dead code.

Whoever is maintaining this PR feel free to add it back.

Copy link
Contributor

@JPercival JPercival Nov 28, 2023

Choose a reason for hiding this comment

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

I did a quick review of cqf-tooling and clinical-reasoning, this function is used when parsing the input reporting period. Since it's only used one place I'm fine either way.

@JPercival JPercival merged commit 75e55e9 into master Nov 28, 2023
2 checks passed
@JPercival JPercival deleted the 863-date-time-interval-inclusion branch November 28, 2023 19: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 interval inclusion and time zone interaction
3 participants