Skip to content

User timezone not taken into account when displaying timestamps (fixes #5038) - #5042

Closed
jmiranda wants to merge 1 commit into
developfrom
5038-user-timezone-ignored
Closed

jmiranda wants to merge 1 commit into
developfrom
5038-user-timezone-ignored

Conversation

@jmiranda

@jmiranda jmiranda commented Feb 12, 2025 •

Copy link
Copy Markdown
Member

This PR attempts to fix a bug (#5038) we noticed recently while performing a discovery on migrating our datetime dependencies from java.util to java.time.

Note: We'll end up consolidating the logic around displaying datetimes later. This is just to fix an annoying bug as unobtrusively as possible.

@github-actions github-actions Bot added the domain: frontend Changes or discussions relating to the frontend UI label Feb 12, 2025
@codecov

codecov Bot commented Feb 12, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.84%. Comparing base (6bb60bc) to head (1a57ddb).
⚠️ Report is 555 commits behind head on develop.

Files with missing lines Patch % Lines
...s-app/taglib/org/pih/warehouse/FormatTagLib.groovy 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5042      +/-   ##
============================================
- Coverage       7.84%   7.84%   -0.01%     
  Complexity       876     876              
============================================
  Files            624     624              
  Lines          42815   42818       +3     
  Branches       10375   10376       +1     
============================================
  Hits            3357    3357              
- Misses         38955   38958       +3     
  Partials         503     503              

☔ 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.

TimeZone tz = session.timezone
if (tz != null) {
df.setTimeZone(tz)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This changes the default behaviour whenever we call <format:date /> with a format that includes the date (not just time).

Did you test how this behaves for dates that don't have a time component such as expiration date?

For example, this one from outgoing/inbound transfers:

<format:date obj="${inventoryItem.expirationDate }"/>

My worry is that despite expiration date not being a precise moment in time (it's just a date), it is still stored as a full datetime object. If we have an expiration date of Jan 1st, 2025, it would be stored as 2025-01-01 00:00:00 UTC. This means if we convert the date to UTC-1 it'll show up as 2024-12-31 23:00:00 UTC-1, which will get formatted as 31/Dec/2024. So depending on where you are, expiration date is different, which I doubt is what we want.

This is a big reason why I wanted to switch to java.time instead. If the field was a LocalDate (instead of Date) it wouldn't be an issue. Date should only be used for precise exact moments in time.

You can test it out to see if my hunch is correct. If so, we'd probably need to do something silly here like check if the date is at midnight and if so, don't timezone convert, but that's not perfect either because we wouldn't be able to represent full datetimes that happen to occur at midnight.

@ewaterman

Copy link
Copy Markdown
Member

I'm going to close this PR since we've implemented a solution in #5474

The format:date taglib has since been deprecated in favour of g:formatDate

@ewaterman ewaterman closed this Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants