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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/cozy-konnector-libs/src/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,20 @@ module.exports = {
}

/**
* This function convert a Date Object to a ISO date string (2018-07-31)
* This function converts a Date Object to its ISO format string ("YYYY-MM-DD")
*
* Parameters:
*
* `date` (Date): the id of the file in the cozy
* `date` (Date): a Date Object
*
* Returns a string
*
* Example:
*
* ```javascript
* const date = formatFrenchDate(New Date.now())
* const date = formatDate(New Date.now())
* ```
*/
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!

}