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

add not woking properly when DST involved #2112

Open
maulik1729 opened this issue Nov 4, 2022 · 1 comment
Open

add not woking properly when DST involved #2112

maulik1729 opened this issue Nov 4, 2022 · 1 comment

Comments

@maulik1729
Copy link

dayjs("11-01-2022").tz("America/Boise", true).add(1, "month").toDate()
dayjs("12-01-2022").tz("America/Boise", true).toDate()
Expected:
Should return same Value
Current:
Getting different values for both

@BePo65
Copy link
Contributor

BePo65 commented Nov 8, 2022

oh, you are right. Why didn't anybody notice this error before? Manipulating a Dayjs object created with a timezone will not adjust the offset.

We get the same (wrong) output, when using a setter, e.g. dayjs("11-01-2022").tz("America/Boise", true).month(12).

As 'add' uses 'set' at the end of the method, I suppose this is the culprit. So we probably will need a 'set' method in the plugin 'timezone' that will call the original 'set' and then adjust the offset. Perhaps the existing 'startOf' method can be used as a template.

How about creating a pr for this? Momentarily I don't have the time for a pr.

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

2 participants