Skip to content

[MDS-6193] Correct NOW Datetime issues#3517

Merged
sggerard merged 3 commits intodevelopfrom
mds-6193-correct-now-dates
May 5, 2025
Merged

[MDS-6193] Correct NOW Datetime issues#3517
sggerard merged 3 commits intodevelopfrom
mds-6193-correct-now-dates

Conversation

@sggerard
Copy link
Contributor

@sggerard sggerard commented May 2, 2025

Objective

MDS-6193

There is a bunch of automated formatting that is slightly obscuring this PR, there are really only two small changes that I have made to fix two issues I was able to find and confirm with the end user Amy.

last_updated_date: This dateTime is set by the backend when a record is updated, and stores a UTC timestamp. However the UTC information was being stripped when being returned by the API and the frontend also wasn't handling UTC. This meant that the last updated date in both the Preamble and on line 1.1 would be wrong in the afternoon.
Screenshot 2025-05-02 at 9 37 58 AM

preamble_date: This date stored on attached documents is not UTC (only stored as a Date in the db) would actually show on the permit correctly, however when displayed in the table it was being treated as a UTC Datetime so was showing incorrectly. This has been corrected by treating preamble_date as only a Date in both the backend and frontend.
image

@sggerard sggerard changed the title Correct last_updated and preamble_date [MDS-6193] Correct NOW Datetime issues May 2, 2025
asinn134
asinn134 previously approved these changes May 2, 2025
Copy link
Collaborator

@asinn134 asinn134 left a comment

Choose a reason for hiding this comment

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

Looks good, just have some errors with tests

@sggerard sggerard added the 👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback. label May 2, 2025
dateString && dateString !== "None" && moment(dateString, "YYYY-MM-DD").format("MMM DD YYYY");

export const formatDateUTC = (dateString) =>
dateString && dateString !== "None" && moment(dateString).format("MMM DD YYYY");
Copy link
Collaborator

@matbusby-fw matbusby-fw May 2, 2025

Choose a reason for hiding this comment

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

Another gradual migration we've introduced is using date-fns rather than moment for dateTime logic since moment has long since been in maintenance mode only. Not the biggest deal since it's still being used in lots of places, but date-fns is much leaner.

Something like:

import { format, parseISO } from 'date-fns';

export const formatDateUTC = (dateString) => 
  dateString && dateString !== "None" ? format(parseISO(dateString), 'MMM dd yyyy') : null;

Didn't test that, so it might need some adjustment.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm down with switching helper date handling to date-fns. I think there's a bunch of tests (mostly snapshots of tables) that should verify it's working as expected- would be nice so long as it doesn't break/change any of those. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a look at moving all the date formatting, and timezone stuff in helpers.ts to date-fns and I think it's a little out of the scope of this ticket. I'm going to update just the method that I have added to date-fns and create a ticket to replace moment with date-fns and date-fns/tz.

asinn134
asinn134 previously approved these changes May 2, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 2, 2025

Quality Gate Passed Quality Gate passed for 'bcgov-sonarcloud_mds_minespace-web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 2, 2025

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 2, 2025

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 2, 2025

Copy link
Collaborator

@matbusby-fw matbusby-fw left a comment

Choose a reason for hiding this comment

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

🙌🏼

@sggerard sggerard merged commit b3c06c4 into develop May 5, 2025
20 checks passed
@sggerard sggerard deleted the mds-6193-correct-now-dates branch May 5, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants