-
-
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
Adding days across daylight savings time in GMT timezone has unexpected result #2238
Comments
I also don't understand why these 2 things are not equal
|
I just ran into what I think is the same issue while adding hours to a date. When that date is midnight on daylight savings day I get a different result than any other day.
I think in my case with hours it might be justified to work this way but was definitely confusing. I am able to work around it by using this instead:
I'm not sure this would be helpful with whole days @bbecker-te but maybe, but it appears to be the same underlying issue |
Also affected by time one. was working as expected only this month started giving weird results. we are trying to get the utc date+time for the next midnight in the specifed timezone |
I have an issue with timezone not changing.
running on:
|
@hadyrashwan That's expected, when converting @bbecker-te Does this happen in other UTC+0 timezones, like "Europe/London"? I've noticed when using those timezones that the UTC flag is set, which it shouldn't be. This causes a lot of issues with arithmetic since the system's TZ ends up getting used for formatting. I submitted #2254 with more details & examples. |
@bbecker-te I let this comment on another issue that probably will help you to solve this issue as well. Let me know if it helped. |
Describe the bug
I am using version 1.11.6 of dayjs.
I have a simple test case for what I think is a dayjs bug. I add 2 days to a day in GMT/UTC timezone and get something that is not on a day boundary. It probably has something to do with daylight savings time because this is when daylight savings time happens in US. However, why its it a 2 hour difference, and why does it happen in GMT/UTC time? This change did not happen when we used moment.js.
Expected behavior
This version of the test should pass. We should not need to add two hours to the expected result.
it('should be exactly two days later when adding two days', function () {
const day1 = dayjs.tz({ year: 2018, month: 2, day: 10 }, 'GMT');
const day2 = day1.add(2, 'day');
expect(day2.valueOf()).toEqual(dayjs.tz({ year: 2018, month: 2, day: 12 }, 'GMT').valueOf());
});
Information
The text was updated successfully, but these errors were encountered: