tz `2023-03-31T04:00:00.000Z` should not be `2023-03-31T04:00:00+08:00`
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
```ts
export function tzDayjs(date?: ConfigType, timezone?: string)
{
if (typeof date === 'string' && date.endsWith('.000Z'))
{
/**
*
* @type {dayjs.Dayjs}
*/
date = dayjs.utc(date)
}
return dayjs.tz(date ?? void 0, timezone ?? TZ_TIME_ZONE)
}
const d1 = tzDayjs('2023-03-31T04:00:00.000Z')
console.log(d1.format())
console.log(d1.toISOString())
const d2 = dayjs.tz('2023-03-31T04:00:00.000Z', TZ_TIME_ZONE)
console.log(d2.format()) // BUG => 2023-03-31T04:00:00+08:00
console.log(d2.toISOString()) // BUG => 2023-03-30T20:00:00.000Z
```
**Expected behavior**
A clear and concise description of what you expected to happen.
```ts
const d2 = dayjs.tz('2023-03-31T04:00:00.000Z', TZ_TIME_ZONE)
console.log(d2.format()) // => 2023-03-31T12:00:00+08:00
console.log(d2.toISOString()) // => 2023-03-31T04:00:00.000Z
```
**Information**
- Day.js Version [e.g. v1.0.0]
- OS: [e.g. iOS]
- Browser [e.g. chrome 62]
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]
Contributor guide
Research direction
Start by reproducing the reported calls to dayjs.tz with `2023-03-31T04:00:00.000Z` and compare `format()` with `toISOString()` against the expected values. Trace the timezone parsing and conversion entry points used by `dayjs.tz`; done means the input preserves its UTC instant while formatting as `2023-03-31T12:00:00+08:00`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100