Skip to content
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

DST issue #1

Open
Darrken opened this issue Oct 16, 2018 · 5 comments
Open

DST issue #1

Darrken opened this issue Oct 16, 2018 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Darrken
Copy link

Darrken commented Oct 16, 2018

Daylight Savings Time seems to be an issue in the plugin.

    let utcDate = dayjs("2016-11-18:00:00:00+00:00");
    console.log(utcDate.utc().format());  // 2016-11-17T23:00:00+00:00

I'd expect 2016-11-18T00:00:00+00:00 to be the value returned.
I found that dates including and between 11/7 - 3/13 have this problem.

Or am I just missing something? (My local offset is -7, observing DST currently.)

@guisturdy guisturdy added the bug Something isn't working label Oct 17, 2018
@myfrom
Copy link

myfrom commented Oct 18, 2018

I'm not sure but from what I've been testing this might be caused because the script always gets the current time offset, not time offset from the specified date.

For example, based on where I am:
I'm in DST now, new Date().getTimezoneOffset() will return -120.
But if I give it a date outside of DST, new Date(27600000).getTimezoneOffset() will return -60.
So in such case, it subtracts two hours from the date instead of one.

I think LOCAL_TIMEZONE_OFFSET should be set dynamically. But as I'm not familiar with the code I might be wrong, what do you think?

@guisturdy guisturdy added the help wanted Extra attention is needed label Oct 28, 2018
@Farkal
Copy link

Farkal commented Nov 28, 2018

Same issue here.
I am in France in august we were UTC+2 and now we are UTC+1.
If I try to convert august timestamp to utc date the hour is just subtracted by one instead of 2.

import dayjs from 'dayjs'
import dayjsPluginUTC from 'dayjs-plugin-utc';

dayjs.extend(dayjsPluginUTC);

const time = '1533722400'

const d = dayjs.unix(time).utc().format()
console.log(d)  // 2018-08-08T11:00:00+00:00 supposed to be 2018-08-08T10:00:00+00:00

const d2 = new Date(time * 1000).getTimezoneOffset()

console.log(d2)  // -120

@danazkari
Copy link
Contributor

I think there's a way to help with DST calculations but it would NOT work on IE11, would that be a problem? If not, I can come up with a PR within the next few days.

@guisturdy
Copy link
Owner

I think there's a way to help with DST calculations but it would NOT work on IE11, would that be a problem? If not, I can come up with a PR within the next few days.

with what reason it would not work on IE11?

@dgrelaud
Copy link

dgrelaud commented Dec 8, 2021

If you have some issues with DST and DaysJS, try my dayjs plugin:
https://www.npmjs.com/package/dayjs-timezone-iana-plugin

cf. comment: iamkun/dayjs#1271 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants