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

provide addInTimeZone function #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dr-skot
Copy link

@dr-skot dr-skot commented Feb 5, 2023

Love this library. One feature it's missing that I've needed from time to time is a timezone-aware version of the date-fns add function.

Time zones matter in date arithmetic because of daylight savings. If your base time is 2022-11-05T06:00Z, for example, and you want to add one day,

in LA it's
11pm Nov 4 + 1 day === 11pm Nov 5 === +24 hrs

but in Halifax it's
3am Nov 5 + 1 day === 3am Nov 6 === +25 hrs

because the clocks fall back 1 hr (in both places) at 2am Nov 6.

So here's a proposed addInTimeZone function to handle that. Plus some tests.

I tried yarn build to generate the typings files but no joy. I guess some more configuration twiddling is needed to make that work.

Hope you find it useful!

timezone-aware version of date-fns.add
@marnusw
Copy link
Owner

marnusw commented Feb 6, 2023

Thank you @dr-skot, I'll take a look in the near future.

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

Successfully merging this pull request may close these issues.

None yet

2 participants