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

Bug in getUnixTime for DST switch #33

Open
simlu opened this issue Apr 5, 2020 · 0 comments
Open

Bug in getUnixTime for DST switch #33

simlu opened this issue Apr 5, 2020 · 0 comments

Comments

@simlu
Copy link

simlu commented Apr 5, 2020

There seems to be a bug in getUnixTime. The unix timestamp is incorrectly generated just after the change to PDT.

I've validated the result and compared the behavior to moment-timezone. See test case below

const moment = require('moment-timezone');
const { findTimeZone, getUnixTime } = require('timezone-support');

const unix1 = getUnixTime(
  { year: 2018, month: 3, day: 11, hours: 5 },
  findTimeZone('America/Vancouver')
) / 1000;
console.log(unix1);
// => 1520773200
// => 1520773200 converts to Sunday March 11, 2018 06:00:00 (am) in time zone America/Vancouver (PDT)
// Reference: https://www.epochconverter.com/timezones?q=1520773200&tz=America%2FVancouver

const unix2 = moment.tz('2018-03-11T05:00:00', 'America/Vancouver').unix();
console.log(unix2);
// => 1520769600
// => 1520769600 converts to Sunday March 11, 2018 05:00:00 (am) in time zone America/Vancouver (PDT)
// Reference: https://www.epochconverter.com/timezones?q=1520769600&tz=America%2FVancouver

Would be great if this could be fixed. It has caused me some headaches as I'm trying to improve performance by migrating from moment-timezone to timezone-support.

Thank you very much for your consideration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant