`tz()` produces incorrect time when passing in milliseconds since the epoch near DST boundary.
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
```ts
const dayjs = require('dayjs');
dayjs.extend(require('dayjs/plugin/utc'));
dayjs.extend(require('dayjs/plugin/timezone'));
// On March 13, 2022 in America/Montreal, at 2:00am, we roll the time back by 1 hour.
// This is the exact millisecond when that happens:
const dstBoundary = 1647154800000;
// This should obviously be true, and it is.
console.log(dayjs.tz(dstBoundary - 1, 'America/Montreal').valueOf() === dstBoundary - 1);
// This should also obviously be true, but it is false. :(
console.log(dayjs.tz(dstBoundary, 'America/Montreal').valueOf() === dstBoundary);
```
**Expected behavior**
When explicitly setting the time as a value in ms since the epoch, dayjs should not change the time we set, but here it does, rewinding time by one hour. `1647154800000` and `1647151200000` are two very different times.
**Information**
- Day.js Version: v1.10.8
- OS: MacOS
- Browser: node v16.14.0
- Time zone: America/Montreal
Contributor guide
Assessment
This issue has not been assessed yet.