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

[Fix 🐛] Update date format in Week component #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leonelhenriquez
Copy link
Contributor

@leonelhenriquez leonelhenriquez commented Sep 3, 2024

The code changes update the date format in the Week component of the Calendar. Instead of using a string to specify the date, it now uses the new Date() constructor with specific parameters. This change improves the readability and maintainability of the code.

The error occurs because the week is iterated using the JavaScript Date constructor as a string, which causes variations between the actual day.

Example of how it's iterated and its result:

new Date('2022-11-6')  // -> Sun Nov 06 2022 00:00:00 GMT-0600
new Date('2022-11-7')  // -> Mon Nov 07 2022 00:00:00 GMT-0600
new Date('2022-11-8')  // -> Tue Nov 08 2022 00:00:00 GMT-0600
new Date('2022-11-9')  // -> Wed Nov 09 2022 00:00:00 GMT-0600
new Date('2022-11-10') // -> Wed Nov 09 2022 18:00:00 GMT-0600
new Date('2022-11-11') // -> Thu Nov 10 2022 18:00:00 GMT-0600
new Date('2022-11-12') // -> Fri Nov 11 2022 18:00:00 GMT-0600

If we iterate using the Date(year, month, day) constructor, these variations do not occur:

new Date(2022,10,6)  // -> Sun Nov 06 2022 00:00:00 GMT-0600
new Date(2022,10,7)  // -> Mon Nov 07 2022 00:00:00 GMT-0600
new Date(2022,10,8)  // -> Tue Nov 08 2022 00:00:00 GMT-0600
new Date(2022,10,9)  // -> Wed Nov 09 2022 00:00:00 GMT-0600
new Date(2022,10,10) // -> Thu Nov 10 2022 00:00:00 GMT-0600
new Date(2022,10,11) // -> Fri Nov 11 2022 00:00:00 GMT-0600
new Date(2022,10,12) // -> Sat Nov 12 2022 00:00:00 GMT-0600

The code changes update the date format in the Week component of the Calendar. Instead of using a string to specify the date, it now uses the `new Date()` constructor with specific parameters. This change improves the readability and maintainability of the code.
@leonelhenriquez
Copy link
Contributor Author

leonelhenriquez commented Sep 3, 2024

Issues: Duplicated week days bug #273

@DreamDevourer
Copy link

Perfect solution on this one, thank you leonelhenriquez!

@ddematheu
Copy link

@onesine any feedback to have this merged? Thanks!

@kayvaninvemo
Copy link

Please merge it, we are experiencing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants