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

Update utils.js #807

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

Update utils.js #807

wants to merge 1 commit into from

Conversation

thibdrev
Copy link

clarifications on the formatDate() function

clarifications on the formatDate() function
@thibdrev thibdrev requested a review from a team as a code owner October 20, 2021 09:07
@Crash--
Copy link
Contributor

Crash-- commented Feb 1, 2022

* ```
*/
function formatDate(date) {
return format(new Date(date), 'yyyy-MM-dd')
return format(new Date(date), 'YYYY-MM-DD')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem does this solve ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md

D and DD that represent the day of a year (1, 2, ..., 365, 366) are often confused with d and dd that represent the day of a month (1, 2, ..., 31).
YY and YYYY that represent the local week-numbering year (44, 01, 00, 17) are often confused with yy and yyyy that represent the calendar year.

// ❌ Wrong!
format(new Date(), 'YYYY-MM-DD')
//=> 2018-10-283

// ✅ Correct
format(new Date(), 'yyyy-MM-dd')
//=> 2018-10-10

So I don't think we should change the format.

We can still cherry-pick the documentation fix!

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.

3 participants