-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parse 'YYYY' correctly #969
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #969 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 169 169
Lines 1429 1430 +1
Branches 305 306 +1
=========================================
+ Hits 1429 1430 +1
Continue to review full report at Codecov.
|
src/index.js
Outdated
|| 1, d[4] || 0, d[5] || 0, d[6] || 0, d[7] || 0)) | ||
} | ||
return new Date(d[1], d[2] - 1, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, d[7] || 0) | ||
return new Date(d[1], d[2] ? d[2] - 1 : 0, d[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If d[2] was undefined, set default value.
@@ -60,10 +60,11 @@ const parseDate = (cfg) => { | |||
const d = date.match(C.REGEX_PARSE) | |||
if (d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const _m = d[2] - 1 || 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I adopted it.
## [1.8.31](iamkun/dayjs@v1.8.30...v1.8.31) (2020-07-29) ### Bug Fixes * Rollback LocalePresetType to string ([#968](iamkun/dayjs#968)) ([b342bd3](iamkun/dayjs@b342bd3)) * Update Regex to parse 'YYYY' correctly ([#969](iamkun/dayjs#969)) ([70c1239](iamkun/dayjs@70c1239))
## [1.8.31](iamkun/dayjs@v1.8.30...v1.8.31) (2020-07-29) ### Bug Fixes * Rollback LocalePresetType to string ([#968](iamkun/dayjs#968)) ([b342bd3](iamkun/dayjs@b342bd3)) * Update Regex to parse 'YYYY' correctly ([#969](iamkun/dayjs#969)) ([70c1239](iamkun/dayjs@70c1239))
## [1.8.31](iamkun/dayjs@v1.8.30...v1.8.31) (2020-07-29) ### Bug Fixes * Rollback LocalePresetType to string ([#968](iamkun/dayjs#968)) ([b342bd3](iamkun/dayjs@b342bd3)) * Update Regex to parse 'YYYY' correctly ([#969](iamkun/dayjs#969)) ([70c1239](iamkun/dayjs@70c1239))
When only 'YYYY', parsed result was incorrect.
Output:
Failed this test in my local env which is in
Asia/tokyo
time zone.Compare dayjs and moment:
So I think expected behavior:
2018-01-01T00:00:00+09:00
.