moment-timezone
moment-timezone copied to clipboard
Functions to get next/last DST transitions
From StackOverflow.
It would be nice to have getNextTransition and related functions.
The function should go in moment proper first, where it will need to scan the local environment's time zone.
Then it can be hooked into moment-timezone such that we use the untils array of a specific time zone.
It would be awesome
You could easily achieve this by getting the moment.tz.zone().untils nearest to current UTC time
Updated the original description. This can all go into moment-timezone, and should use the functions we created as part of the .guess() function when working with an regular moment object in local mode.
Is this still needed? The stack overflow thread no longer exists, so I'm not sure about what the requirements/context are. Otherwise would love to take this task if not too complex (this would be my first PR to moment js). Thanks!!
@petrgazarov - Yes, it's still needed. The example in the S.O. thread was:
moment().tz('Europe/Paris').getNextDST();
I'm not sure that's the exact API that we'd want, but something like that. A proposal would be welcome.
@mj1856 I would like to work on this issue, where can I hook the new function?
can you add these Functions to the Zone Object? So I can do moment.ts.zone('Europe/Berlin').getNextTransition(date).isDST() and getPreviousTransition(date)
Yes, you should be able to hook the zone.
There is already a PR for this for those interesting in reviewing: https://github.com/moment/moment-timezone/pull/431 😃
I followed @mj1856 's example, but hooking it up to Zone object shouldn't be a big deal.