Skip to content

DST transition does not work correctly #58

@alexeyvokin

Description

@alexeyvokin

DST transition does not work correctly.

Set up the local Europe/Amsterdam time zone on your device.

Code:

import moment from "moment";
import "moment-business-time";

moment.updateLocale("nl", {
  workinghours: {
    0: ["00:00:00", "10:00:00"],
    1: ["00:00:00", "10:00:00"],
    2: ["00:00:00", "10:00:00"],
    3: ["00:00:00", "10:00:00"],
    4: ["00:00:00", "10:00:00"],
    5: ["00:00:00", "10:00:00"],
    6: ["00:00:00", "10:00:00"]
  }
});

const dstTime = new Date("2022-10-30 02:00:00 UTC+0200");
const dstTimeThen = moment(+dstTime)
  .addWorkingTime(1, "hour")
  .toDate(); // also "2022-10-30 02:00:00 UTC+0200", but should be "2022-10-30 02:00:00 UTC+0100"

console.log("is equal:", dstTime.valueOf() === dstTimeThen.valueOf()); // true

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