Skip to content

Bug in getUnixTime for DST switch #33

@simlu

Description

@simlu

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions