-
-
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
Timezone conversion incorrect when daylight saving in effect #1260
Comments
is this whats going wrong in the test suite of this library? i ran it and some tests were off by an hour. |
Hi, any thoughts on this issue @iamkun? |
I can confirm that tests are failing in a locale affected by daylight savings (I'm in I found out because tests stared breaking locally, and I made some experiments showing output different from Moment: https://runkit.com/lucasrcosta/5feca83aea7c09001b879b3a I tried sorting it out on the code and removing the current offset from Summary of all failing tests
|
This bug sounds similar to the recent comment in this one: #1340 (comment) I'm going to cross-post the bug and how it can be fixed. Let me know if that doesn't actually fix this.
|
A fix was applied in #1352 that may fix this bug. Can someone try with the latest changes and see if the issue still persists? |
Still brakes here, although a little different...
|
I'm getting the same problem now that we're in BST, I'm in
Clearly wrong, any suggestions? |
Has this been fixed?. I am having the same issue with a few different time zones that apply daylight savings time, or has anyone been successful with any work around?, |
It sounds like it hasn't. I thought #1352 would fix it but others have reported not. Note that these changes are not officially released. In other words, you have to use the If you're interested, try with the |
Thanks for the tip. I've tried to install the dev branch however it still does not fix my issue. |
Seems the issue still in place. I tried to run this script in different time zones and got quite diverged results. console.log(dayjs("2027-10-31T00:00:00Z").tz("Europe/Berlin").format());
console.log(dayjs("2027-10-31T01:00:00Z").tz("Europe/Berlin").format()); // +1hr ServerTime: Wed Sep 15 2021 08:14:59 GMT+0200 (Central European Summer Time)
ServerTime: Wed Sep 15 2021 07:15:53 GMT+0100 (British Summer Time)
ServerTime: Wed Sep 15 2021 16:16:46 GMT+1000 (Vladivostok Standard Time)
This issue affects also development process when remote developers run it on their own local machines across the world. I expect to have the same result which is not related to the server's timezone. Please correct me if I'm wrong. |
The problem is still relevant. |
Last November we moved from |
@CoreyKovalik we have a big project, it will be much longer to switch to luxon, due to the API differences. |
a year and a half after this bug was reported and it's still no fixed? damn... should i revert to momentjs after all? |
@AComasSamcla I didn't check, but looks like fixed in https://github.com/iamkun/dayjs/releases/tag/v1.11.2 fix UTC plugin .valueOf not taking DST into account (#1448) (27d1c50) |
@Serg-Mois oh nice, i checked it and seems fixed now, so probably this issue could be closed by @iamkun too. |
The issue remains,
EDIT: updated to 1.11.6, the issue remains.
Verified with unixtimestamp.com and python. EDIT2: If the time is specified this way then the conversion is correct,
|
was there ever a solution for this? |
Just noting that this is still an issue in 1.11.10 |
Any updates on this issue? Still facing the same in latest version |
I am with the same problem. |
Same here, facing issues with DST handling. |
It's been almost 4 years and still no fix.. I just came across the same issue. |
Ha, I came across the same issue and couldn't figure it out until reading this --- is this still not fixed? |
I'm not sure if I got this wrong, but for whatever reason setting the 'keepLocalTime' to 'false' will correctly display the time in regions affected by DST. I have a function like this: function getHRT(datetime) {
return dayjs(datetime)
.tz(timezone, false) // Put the 'false' here when setting the timezone.
.format(date_format + ', ' + time_format);
} I'm working with a VILT stack, not sure if that has anything to do with it. |
@amir-huseinspahic I don't think it is meant for that. See when keepLocalTime was introduced: #1149 It seems to me that if you want to say it is 6:00 in timezone 1 and want to change it to 6:00 in timezone 2, then pass in keepLocalTime = true. Otherwise, it will change the time to match the same moment 6:00 in timezone 1. If keepLocalTime works, that's interesting, but it may not always. |
Workaround for me due to confusion on timezones is to use Date directly for this purpose (which I only need in one spot in my code) whereas I use dayjs in many areas.
tl;dr - I really just use this only in my code:
You could instead pull your dayjs formatted date and put into the Date object or compare to the system time somehow or find some other way to use the IANA database if issues with dayjs until dayjs is updated. I played with Date code here: Another workaround: #1388 (comment) |
If such a core bug affecting so many users hasn't been fixed in 4 years, consider |
I switched to Luxon due to problems with timezones/utc offsets in Dayjs (#2741) |
Unpacked Size 4.48 MB Seriously? 😵💫 |
I know. Size and popularity was the reason I started with Dayjs. But I needed a working timezone and UTC offset support. Maybe it's bigger, but compare the number of issues on GH. Plus documentation is great. I don't regret switching. Edit: after re-reading the above, maybe I'm too biased. I don't know both libraries well enough to give such opinions. Maybe it's just my specific use cases that don't work with one library but work with the other. |
Describe the bug
Dayjs does not seem to convert timezone correctly when DST is in effect. It produces different results from Moment. The Moment results seem intuitively what I'd expect, so believe to be correct unless there is some subtlety I'm missing.
Expected behavior
With this code:
The output is:
Information
The text was updated successfully, but these errors were encountered: