iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
46.97k stars 2.3k forks source link

[regression] dayjs.tz is overriding ISO format tz #1686

Open isaacl opened 3 years ago

isaacl commented 3 years ago

In 1.10.6

+d.tz("2021-11-18T00:15:00Z", "America/New_York") === +d("2021-11-18T00:15:00Z")

In 1.10.7 These are no longer equal.

Expected behavior when parsing a UTC string, d.tz wouldn't interpret the time differently, but rather would just set the timezone after parsing as a UTC time. But now it handles this differently. It is interpreting the string in the context of America/New_York timezone.

Information

isaacl commented 3 years ago

This behavior has changed since 1.10.6 in 1.10.6:

> +d("2021-11-18T00:15:00Z").tz('America/New_York')
1637194500000
> +d.tz("2021-11-18T00:15:00Z", "America/New_York")
1637212500000
isaacl commented 2 years ago

Hmm OK I was wrong that this was a recent regression. In 1.9.7 however, dayjs.tz does handle isostrings correctly. So I guess this is more of a feature request?