moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

Functions to get next/last DST transitions

Open mattjohnsonpint opened this issue 10 years ago • 9 comments

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.

mattjohnsonpint avatar Oct 30 '15 04:10 mattjohnsonpint

It would be awesome

fakenickels avatar Nov 02 '15 20:11 fakenickels

You could easily achieve this by getting the moment.tz.zone().untils nearest to current UTC time

desnyki avatar Feb 17 '16 20:02 desnyki

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.

mattjohnsonpint avatar Feb 17 '16 23:02 mattjohnsonpint

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 avatar Oct 08 '16 20:10 petrgazarov

@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.

mattjohnsonpint avatar Oct 26 '16 18:10 mattjohnsonpint

@mj1856 I would like to work on this issue, where can I hook the new function?

mnunezNearsoft avatar Nov 05 '16 00:11 mnunezNearsoft

can you add these Functions to the Zone Object? So I can do moment.ts.zone('Europe/Berlin').getNextTransition(date).isDST() and getPreviousTransition(date)

getriebesand avatar Jan 23 '17 19:01 getriebesand

Yes, you should be able to hook the zone.

maggiepint avatar Jan 26 '17 18:01 maggiepint

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.

petrgazarov avatar Jan 27 '17 00:01 petrgazarov