fix: incorrect startOf/endOf behavior with +00:00 timezone
fix: incorrect startOf/endOf behavior with +00:00 timezone
assume I'm in +08:00, when I parse time string with any regions in +00:00(like UTC, Africa/Abidjan), got the incorrect result
example: incorrect in dayjs:
dayjs.tz('2021-04-01', 'Asia/Hong_Kong').endOf('day').format()
// "2021-04-01T23:59:59+08:00"
dayjs.tz('2021-04-01', 'Africa/Abidjan').endOf('day').format()
// "2021-04-01T15:59:59Z"
dayjs.tz('2021-04-01', 'UTC').endOf('day').format()
// "2021-04-01T15:59:59Z"
expect work like moment
moment.tz('2021-04-01', 'Asia/Hong_Kong').endOf('day').format()
// "2021-04-01T23:59:59+08:00"
moment.tz('2021-04-01', 'Africa/Abidjan').endOf('day').format()
// "2021-04-01T23:59:59Z"
moment.tz('2021-04-01', 'UTC').endOf('day').format()
// "2021-04-01T23:59:59Z"
clone form #1506
sorry for open this PR multi-time, look like there is some problem with Travis-CI and I'm trying to solve this with Travis support, this PR is a test for Travis support.
Thanks.
It is odd that the PR sent from your account could not trigger the CI. But the rest looks fine.
I run the npm test on my locale machine and it fails with some errors.
I pass all the tests on my machine, can you share the error?
still talking to Travis support 🥲
Codecov Report
Merging #1512 (2f1490b) into dev (b3ab757) will not change coverage. The diff coverage is
n/a.
:exclamation: Current head 2f1490b differs from pull request most recent head e49ecaa. Consider uploading reports for the commit e49ecaa to get more accurate results
@@ Coverage Diff @@
## dev #1512 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 183 176 -7
Lines 2111 1973 -138
Branches 554 501 -53
==========================================
- Hits 2111 1973 -138
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/plugin/timezone/index.js | 100.00% <ø> (ø) |
finally... CI work
@iamkun this PR has been open for a long time, just want to know dayjs considers this behavior normal or a bug?
According to your fix, is that mean, we should not update the startOf func in a timezone plugin, and the problem is solved?
@iamkun hi, It appears that this issue still exists. I update the code with latest version, would be great you can take a look on this.
reply your last comment: yes, I think we should not update startOf func in a timezone plugin
I found that these line break $D,$H...etc https://github.com/iamkun/dayjs/blob/1e9ba761ff4e3f2759106dfe1aa9054d5826451c/src/plugin/timezone/index.js#L123-L125
dayjs.tz('2021-05-10 00:00:00', 'UTC')
$d: Mon May 10 2021 00:08:00 GMT+0800 (China Standard Time)
$D: 10
$H: 0
$L: 'en'
$m: 0
$M: 4
$ms: 0
$s: 0
$u: undefined
$W: 1
$x: {}
$y: 2021
// startOfWithoutTz.tz(this.$x.$timezone, true)
$d: Mon May 10 2021 00:00:00 GMT+0800 (China Standard Time)
$D: 9
$H: 16
$L: 'en'
$m: 0
$M: 4
$ms: 0
$offset: 0
$s: 0
$u: true
$W: 0
$x: {$timezone: 'UTC'}
$y: 2021
then format func will return incorrect format string