moment-recur
moment-recur copied to clipboard
Matching 4th weekday of month when recurrence started with 5th weekday of month
In Google Calendar, when you start a recurrence with let's say the 5th monday of a month, on the next month if there is only 4 mondays it will match the last one. I would expect this library to do the same.
Here's a test case scenario:
moment({ date: 31, month: 2, year: 2014 }) // 5th monday of march 2014
.recur()
.every(1).daysOfWeek() // monday
.every(4) // fifth monday
.weeksOfMonthByDay()
.matches(moment({ date: 31, month: 7, year: 2015 })) // aug 31st 2015, 5th monday
// returns true
moment({ date: 31, month: 2, year: 2014 }) // 5th monday of march 2014
.recur()
.every(1).daysOfWeek() // monday
.every(4).weeksOfMonthByDay() // fifth monday
.matches(moment({ date: 24, month: 10, year: 2014 })) // nov 24th 2014, 4th monday
// returns false
Thank you
I created a PR that allows you to match against the last (or second to last, etc) week of the month by day that might help with this use-case. See: c-trimm/moment-recur/pull/53
You should be able to use simple-recur
as an alternative to this project (there are several core bugs described in #85). See https://github.com/jamiter/simple-recur.
I'm waiting on a PR to merge for better documentation for that repo at https://github.com/jamiter/simple-recur/pull/3 -- so until that is resolved you can view better docs at https://github.com/niftylettuce/simple-recur/tree/patch-1#simple-recur in the meanwhile.