Last active
May 24, 2016 17:54
-
-
Save banjeremy/f36a5bac846b66c255bec37ac26ee711 to your computer and use it in GitHub Desktop.
checks if a given day is an occurance in a recurrence rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function isDayAnOccurance(day, recurrenceRule) { | |
const rule = RRule.fromString(recurrenceRule); | |
// Convert all dates into UTC before comparison | |
const today = moment(day).utc().startOf('day'); | |
const nextOccurrence = moment(rule.after(today, true)).utc(); | |
const match = moment(nextOccurrence).isSame(today, 'day'); | |
return match; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment