dayjs.tz vs dayjs().tz functionality difference is confusing
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Using `dayjs.tz(date, timezone)` and `dayjs(date).tz(timezone)` produce different results when the passed date string has a timezone offset defined but the same result when there is no timezone defined
See the following code:
```js
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz('2015-06-23T00:45:33+00:00', 'America/New_York').format() === dayjs('2015-06-23T00:45:33+00:00').tz('America/
New_York').format() //returns false
dayjs.tz('2015-06-23T00:45:33', 'America/New_York').format() === dayjs('2015-06-23T00:45:33').tz('America/
New_York').format() //returns true
```
**Expected behavior**
I would expect the behavior of `dayjs.tz` and `dayjs().tz` to be the same in this case
**Information**
- Day.js Version ^1.10.6
- OS: Windows 10
- Browser Chrome 96
- Time zone: Eastern Standard Time (GMT-05:00)
Contributor guide
Research direction
Start by running the provided reproduction with the utc and timezone plugins, comparing dayjs.tz(date, timezone) with dayjs(date).tz(timezone) for strings with and without an offset. Read the utc and timezone plugin entry points to trace the differing parsing paths. Done means the two entry points have consistent results for both examples, with regression coverage for the offset case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100