Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: date and time standardization all across the platform. #3283

Merged
merged 6 commits into from
Jan 2, 2024

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Dec 29, 2023

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 13:00:00") // 13:00
  • Usage: renderFormattedTime("2024-01-01 13:00:00", "12-hour") // 01:00 PM

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.

@aaryan610 aaryan610 marked this pull request as ready for review January 2, 2024 09:00
@sriramveeraghanta sriramveeraghanta merged commit 1539340 into develop Jan 2, 2024
6 of 8 checks passed
sriramveeraghanta pushed a commit that referenced this pull request Jan 22, 2024
* chore: date and time standardization all across the platform.

* chore: update `renderFormattedTime` function.
* remove unwanted code.

* fix: build errors

* chore: update `renderFormattedTime` function params.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants