Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling .tz("UTC", true) after .tz("UTC") on the same object seems to mutate it #2719

Open
KevinMoran99 opened this issue Aug 26, 2024 · 0 comments

Comments

@KevinMoran99
Copy link

Describe the bug
When creating a dayjs object and changing its timezone to any zone with 0 offset (UTC, in this example, for simplicity), then calling .tz("UTC", true) on the same object, it appears as if it has some kind of mutation.

Using isSame to compare the object with a copy of itself that was declared before calling .tz("UTC", true) returns false, although in the console both objects seem to have equal values.

Reproduction on Codesandbox

image image

As stated, this happens with all zones with 0 offset, so, for instance, replacing 'UTC' with 'Africa/Abidjan' in the code yields the same result.

In general, everything utc related seems to be kinda weird right now, as there are some other shenanigans that I have encountered in our actual project but can't find a way to properly reproduce them in an isolated environment.


Expected behavior
isSame should return true due to immutability.


Information

  • Day.js Version: v1.11.13
  • OS: macOS Monterey 12.5
  • Browser: Chrome 127
  • Time zone: GMT-06:00, also happens when using the browser's console to emulate a timezone with a positive offset, such as GMT+01:00.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@KevinMoran99 and others