plane
plane copied to clipboard
chore: date and time standardization all across the platform.
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
- Description: Returns the formatted date in the format of "MMM dd, yyyy".
- Usage:
renderFormattedDate("2024-01-01") // Jan 01, 2024
renderFormattedDateWithoutYear
- Description: Returns the date in the format of "MMM dd" without the year.
- Usage:
renderFormattedDateWithoutYear("2024-01-01") // Jan 01
renderFormattedPayloadDate
- Description: Returns the date in the format of "yyyy-mm-dd" suitable for payload use.
- Usage:
renderFormattedPayloadDate("Jan 01, 2024") // "2024-01-01"
renderFormattedTime
- Description: Returns the formatted time in either 12-hour or 24-hour format.
- Usage:
renderFormattedTime("2024-01-01", true) // 12:00 AM
findTotalDaysInRange
- Description: Calculates the total number of days between two dates.
- Usage:
findTotalDaysInRange("2021-01-01", "2021-01-08") // 8
findHowManyDaysLeft
- Description: Computes the number of days left from today to the given date.
- Usage:
findHowManyDaysLeft("2024-01-01") // 3
calculateTimeAgo
- Description: Returns the time passed since the event happened.
- Usage:
calculateTimeAgo("2023-01-01") // 1 year ago
isDateGreaterThanToday
- Description: Checks if the provided date is greater than today's date.
- Usage:
isDateGreaterThanToday("2024-01-01") // true
Other Fixes:
- Removed unnecessary date functions to keep things consistent.
- Improved existing functions to use the date-fns methods, making the code more understandable and easier to manage.
- Checked and ensured that all date-related functions now use date-fns for consistency.