chore: date and time standardization all across the platform. #3283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes sure all dates and times throughout the platform look and work consistently. I have cleaned up the code, and implemented all the functions using date-fns to handle dates and times better, making everything easier to understand and use.
Problem:
The date and time presentation were inconsistent across the platform, causing confusion in how dates and times were shown.
Solution:
Implemented standardized date and time handling using the
date-fns
library. The existing helper functions were refactored or replaced.Functions Updated:
renderFormattedDate
renderFormattedDate("2024-01-01") // Jan 01, 2024
renderFormattedDateWithoutYear
renderFormattedDateWithoutYear("2024-01-01") // Jan 01
renderFormattedPayloadDate
renderFormattedPayloadDate("Jan 01, 2024") // "2024-01-01"
renderFormattedTime
renderFormattedTime("2024-01-01 13:00:00") // 13:00
renderFormattedTime("2024-01-01 13:00:00", "12-hour") // 01:00 PM
findTotalDaysInRange
findTotalDaysInRange("2021-01-01", "2021-01-08") // 8
findHowManyDaysLeft
findHowManyDaysLeft("2024-01-01") // 3
calculateTimeAgo
calculateTimeAgo("2023-01-01") // 1 year ago
isDateGreaterThanToday
isDateGreaterThanToday("2024-01-01") // true
Other Fixes: