-
-
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
fix: utcOffset when local in DST but date is not #1448
Conversation
Fixes a bug in the valueOf() function after setting a utcOffset, when the the local timezone offset changes. I added a test for it to test/timezone.test.js, so it should be reproducible on other people's computers as well.
I don't know why this PR shows "This branch has not been deployed". Would you please close it and re-open a new one? |
Codecov Report
@@ Coverage Diff @@
## dev #1448 +/- ##
===========================================
+ Coverage 99.94% 100.00% +0.05%
===========================================
Files 176 179 +3
Lines 1770 1996 +226
Branches 411 507 +96
===========================================
+ Hits 1769 1996 +227
+ Misses 1 0 -1
Continue to review full report at Codecov.
|
Hello 👋, any updates on this PR? Looks like it can fix a problem mentioned lately in that issue #1437, which I also encountered in my project. |
I don't actually know if it will fix #1437, since I have only tested this for using utc offsets (not timezones), when you are running dayjs in a region that has daylight savings. It does look like a similar issue though, so hopefully it does fix that issue, but unless somebody writes a test for #1437, we can't be sure. |
Thanks for the work on this @aloisklink. |
This PR resolves off-by-one errors I've been encountering |
There have been a few issues that are probably related to this (#1635, #1622), and more are coming as we are nearing the DST change (last sunday of September here in NZ). |
On my machine (EEST, UTC+3) there are 7 test failures on vanilla dev/master branches. @iamkun is there any blocking reason why this isn't merged yet? If there is anything changeable - I can help. |
I actually applied this fix to utc.js in my node_modules folder. It seems to have fixed the issue when converting timezones |
For those who are waiting on this PR, you can apply this fix in your application by means of a plugin, like we've done here https://github.com/wellcomecollection/wellcomecollection.org/blob/32af11a4169a0a91ff3e1efd2cf2bf919d61fb90/common/utils/dates.ts#L37-L45 |
Bump for asking why this is not being resolved? Seems to be effecting a lot of timezone/utc issues people are having |
@iamkun any change to get this in? |
bump - @iamkun we are experience a similar issue in our production env regarding timezone/offset from UTC, so if the PR is ready, what is waiting? Currently we experience that Europe/Copenhagen timezone shows wrong offset '$offset': 120, - it should be '$offset': 60 due to european winter time :) Using version: 1.10.6 |
@msal4 - Any idea when this can get pulled? |
the fix few comments up works fine. Use that. Seems weird that there is no reaction to this, since dayjs has the wrong time for most of europe, maybe every DST region... |
This PR did not work in my case so I have created an alternative DaysJS plugin for timezone. cf. my comment: #1271 (comment) |
Add more test to fix utcOffset DST
I don't know how this is supposed to work, but if I do something like
and move through the months with a date picker, in March, start of month becomes -6:00GMT instead of -7:00GMT, and once I hit December it goes back to -8:00 GMT. Why does it change by 2 hours? |
## [1.11.2](v1.11.1...v1.11.2) (2022-05-06) ### Bug Fixes * add OpUnitType (week) to quarterOfYear startOf/endOf types ([#1865](#1865)) ([400bc3e](400bc3e)) * Fix type issue with ManipulateType ([#1864](#1864)) ([d033dfc](d033dfc)) * fix UTC plugin .valueOf not taking DST into account ([#1448](#1448)) ([27d1c50](27d1c50))
🎉 This PR is included in version 1.11.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [1.11.2](iamkun/dayjs@v1.11.1...v1.11.2) (2022-05-06) ### Bug Fixes * add OpUnitType (week) to quarterOfYear startOf/endOf types ([#1865](iamkun/dayjs#1865)) ([400bc3e](iamkun/dayjs@400bc3e)) * Fix type issue with ManipulateType ([#1864](iamkun/dayjs#1864)) ([d033dfc](iamkun/dayjs@d033dfc)) * fix UTC plugin .valueOf not taking DST into account ([#1448](iamkun/dayjs#1448)) ([27d1c50](iamkun/dayjs@27d1c50))
Fixes a bug in the valueOf() function after setting a utcOffset, when the the local timezone offset changes.
I added a test for it to
test/timezone.test.js
, so it should be reproducible on other people's computers as well.Without this fix, when trying to run
npm test
in my timezone (British Summer Time - BST), there are quite a lot of off-by-one errors, e.g.