You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to recommend adding a count parameter to the "Between" functionality. This functionality exists in the Python version and is quite useful here.
I've seen it while trying to check if today is in the recurrence. The standard way to do that is using "after", testing for null and then checking it happens today:
function isDayInRole(roleSettings, timestamp) {
const startOfDay = moment(timestamp).startOf('day');
const rule = new RRule(roleSettings);
const next = rule.after(start);
return next && moment(next).isSame(startOfDay, 'day');
}
Which prevent the simple one-liner of the logic (the last two lines).
A second approach is to use Between and see we got results:
But this can take a long time since it runs on all occurrences (think of minutely).
Given the option of count can help these kind of test as between(after,before,count=1) will act as isBetween functionality withouth the overhead of converting/running a long loop.
On the same note, isBetween will also help me with my need, but count can also help the issue of infinite loop I've seen: #481
Thanks,
Moshe
The text was updated successfully, but these errors were encountered:
Hi,
I would like to recommend adding a count parameter to the "Between" functionality. This functionality exists in the Python version and is quite useful here.
I've seen it while trying to check if today is in the recurrence. The standard way to do that is using "after", testing for null and then checking it happens today:
Which prevent the simple one-liner of the logic (the last two lines).
A second approach is to use Between and see we got results:
But this can take a long time since it runs on all occurrences (think of minutely).
Given the option of count can help these kind of test as
between(after,before,count=1)
will act as isBetween functionality withouth the overhead of converting/running a long loop.On the same note, isBetween will also help me with my need, but count can also help the issue of infinite loop I've seen:
#481
Thanks,
Moshe
The text was updated successfully, but these errors were encountered: