moment-recur-ts icon indicating copy to clipboard operation
moment-recur-ts copied to clipboard

Recurrence with ranges

Open luke-hawk opened this issue 7 years ago • 2 comments

I'm using moment-range because of it's powerful querying as I need to check whether a certain range lays within another range. Basically, I have different seasons and I need to check whether a period of time lays within that season.

However, as those seasons are recurring every year I was wondering whether it was possible to make moment-recur-ts work with moment-range? Do you have any idea how I could achieve it? I've tried everything I could think of and am kind of stuck here. Any advice highly appreciated!

luke-hawk avatar Jan 30 '18 16:01 luke-hawk

I haven’t used moment-range, so I’m not sure if it will be easy to integrate. One gotcha I’ve noticed when using multiple moment plugins is making sure to only load one version of moment (details are specific to your module loading framework). For instance, I use yarn and add a ‘resolutions’ section to force all the plugins to use the same moment version.

I’m on vacation for two more weeks, will take a look when I get back.

On Jan 30, 2018, at 5:50 PM, luke-hawk [email protected] wrote:

I'm using moment-range because of it's powerful querying as I need to check whether a certain range lays within another range. Basically, I have different seasons and I need to check whether a period of time lays within that season.

However, as those seasons are recurring every year I was wondering whether it was possible to make moment-recur-ts work with moment-range? Do you have any idea how I could achieve it? I've tried everything I could think of and am kind of stuck here. Any advice highly appreciated!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

jefbarn avatar Feb 02 '18 10:02 jefbarn

@luke-hawk If your 'seasons' are defined as particular weeks or months of a year, then using this library could work. If the seasons are based on particular dates of the year (that aren't on week boundaries) then it's not supported currently. A possible enhancement is adding a 'daysOfYear' recurrence pattern that would solve this. Then to check your range you would iterate over each day and check if it matches the recurrence.

jefbarn avatar Feb 17 '18 20:02 jefbarn