Skip to content

OBPIH-7255: add support for ZonedDateTime to backend#5237

Merged
ewaterman merged 3 commits intodevelopfrom
ft/OBPIH-7255-zoneddatetime-support
May 23, 2025
Merged

OBPIH-7255: add support for ZonedDateTime to backend#5237
ewaterman merged 3 commits intodevelopfrom
ft/OBPIH-7255-zoneddatetime-support

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Apr 29, 2025

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7255

Description:

  • Switch Instant to error if time or zone aren't provided instead of defaulting to midnight UTC (Instant isn't being used anywhere yet so this is safe to do)
  • Add support for parsing ZonedDateTime. ZDT is like Instant except it preserves timezone (Instant is only a UTC timestamp) so is needed for exports and GSPs where we need the backend to know what timezone to display
  • Add XForDisplay methods for converting these data types to Strings for display (used by GSPs, and data exporters).

@ewaterman ewaterman self-assigned this Apr 29, 2025
@github-actions github-actions bot added the type: feature A new piece of functionality for the app label Apr 29, 2025
@codecov
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

❌ Patch coverage is 44.44444% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.29%. Comparing base (e6c82a5) to head (0d86b85).
⚠️ Report is 152 commits behind head on develop.

Files with missing lines Patch % Lines
grails-app/utils/org/pih/warehouse/DateUtil.groovy 33.33% 8 Missing and 10 partials ⚠️
...use/databinding/ZonedDateTimeValueConverter.groovy 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5237      +/-   ##
============================================
- Coverage       8.31%   8.29%   -0.02%     
- Complexity       971     982      +11     
============================================
  Files            638     641       +3     
  Lines          43246   43317      +71     
  Branches       10511   10525      +14     
============================================
- Hits            3596    3594       -2     
- Misses         39097   39163      +66     
- Partials         553     560       +7     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions github-actions bot added the domain: backend Changes or discussions relating to the backend server label May 13, 2025
// default and replace it with "withZone" when parsing (see DateUtil.asDate).
// https://stackoverflow.com/questions/41999421/how-does-datetimeformatters-override-zone-work-when-parsing
// Defaults to the current timezone offset of the system if timezone is not provided in the String.
.parseDefaulting(ChronoField.OFFSET_SECONDS, DateUtil.getSystemZoneOffset().getTotalSeconds())
Copy link
Member Author

Choose a reason for hiding this comment

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

This line is the only change in the whole PR that actually has any impact on existing code. Everything else isn't being used anywhere yet (except for tests).

This change doesn't have any impact on PIH servers since our tz is UTC, but it allows other servers (such as dominica) which are set up with a non-UTC timezone to be able to handle the case where timezone isn't provided by the frontend.

@ewaterman ewaterman merged commit fd285c1 into develop May 23, 2025
9 checks passed
@ewaterman ewaterman deleted the ft/OBPIH-7255-zoneddatetime-support branch May 23, 2025 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant