[MDS-6193] Correct NOW Datetime issues#3517
Conversation
asinn134
left a comment
There was a problem hiding this comment.
Looks good, just have some errors with tests
| 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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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.
|
|
|
|



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.

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.
