iamkun / iamkun/dayjs

Between 1.10.4 -> 1.10.5, dayjs.tz value has changed.

Open
#2,258 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I notice something very important thing has changed between 1.10.4 -> 1.10.5
```
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

const englandTime = "Africa/Abidjan"; // UTC+0
const korea = "Asia/Seoul"; // UTC+9

dayjs.extend(utc);
dayjs.extend(timezone);
process.env.TZ = englandTime; // Node Default time
dayjs.tz.setDefault(korea);
```

This is my test
```
import "./consoleColorFy";
import "./lib/dayjsConfig";
import dayjs from "dayjs";
import { TimePerMs } from "./api/Commons/shared/enums.type";

const starnd = 1678806000000;
const compare = 1678806000000 + TimePerMs.H * 24;

const tzToDate = dayjs.tz(1678806000000).toDate();
const toDate = dayjs(1678806000000).toDate();
const tzFormat = dayjs.tz(1678806000000).format("YYYY-MM-DD HH:mm:ss");
const toDateFormat = dayjs(1678806000000).format("YYYY-MM-DD HH:mm:ss");
const tzValue = dayjs.tz(1678806000000).valueOf();
const value = dayjs(1678806000000).valueOf();

const tzDiffHour = dayjs.tz(1678806000000).diff(compare, "hour");
const tzDiffDay = dayjs.tz(1678806000000).diff(compare, "day");
const tzDiffDate = dayjs.tz(1678806000000).diff(compare, "date");

const diffHour = dayjs(1678806000000).diff(compare, "hour");
const diffDay = dayjs(1678806000000).diff(compare, "day");
const diffDate = dayjs(1678806000000).diff(compare, "date");

console.log({
tzToDate,
toDate,
toDateFormat,
tzFormat,
diffHour,
diffDay,
tzDiffHour,
tzDiffDay,
tzDiffDate,
diffDate,
tzValue,
value,
});
```

dayjs 1.10.4 result.
```
{
tzToDate: 2023-03-14T06:00:00.000Z,
toDate: 2023-03-14T15:00:00.000Z,
toDateFormat: '2023-03-14 15:00:00',
tzFormat: '2023-03-15 00:00:00',
diffHour: -24,
diffDay: -1,
tzDiffHour: -33,
tzDiffDay: -1,
tzDiffDate: -118800000,
diffDate: -86400000,
**tzValue: 1678773600000,
value: 1678806000000**
}
```

dayjs 1.10.5 result.
```
{
tzToDate: 2023-03-14T15:00:00.000Z,
toDate: 2023-03-14T15:00:00.000Z,
toDateFormat: '2023-03-14 15:00:00',
tzFormat: '2023-03-15 00:00:00',
diffHour: -24,
diffDay: -1,
tzDiffHour: -24,
tzDiffDay: -1,
tzDiffDate: -86400000,
diffDate: -86400000,
tzValue: 1678806000000,
value: 1678806000000
}
```

**How could this be a minor change?**
This can break my app seriously.

I tried to find something in the CHANGE_LOG file, but couldn't.
Please, I need to know what is going on now.

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied comparison using the utc and timezone plugins, focusing on dayjs.tz(...).toDate(), valueOf(), and diff(). Review the timezone plugin entry point and CHANGE_LOG for the 1.10.4–1.10.5 change. Done means determining the intended behavior and documenting or correcting the regression consistently with the reported results.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.