Skip to content

Commit

Permalink
Add check for the origin of the rrule (or rruleSet) object and create…
Browse files Browse the repository at this point in the history
… dateEnv markers if the origin was a string
  • Loading branch information
joelzanden committed Apr 8, 2020
1 parent 1abe7f2 commit 6b525ec
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/rrule/src/main.ts
Expand Up @@ -39,14 +39,18 @@ let recurring: RecurringType = {
return null
},

expand(rrule: RRule, framingRange: DateRange): DateMarker[] {
expand(rrule: RRule, framingRange: DateRange, dateEnv: DateEnv): DateMarker[] {
// we WANT an inclusive start and in exclusive end, but the js rrule lib will only do either BOTH
// inclusive or BOTH exclusive, which is stupid: https://github.com/jakubroztocil/rrule/issues/84
// Workaround: make inclusive, which will generate extra occurences, and then trim.
return rrule.between(framingRange.start, framingRange.end, true)
.filter(function(date) {
return date.valueOf() < framingRange.end.valueOf()
})
if (rrule['fromString'] === true) {
return rrule.between(framingRange.start, framingRange.end, true)
.map(date => dateEnv.createMarker(date))
.filter(date => date.valueOf() < framingRange.end.valueOf())
} else {
return rrule.between(framingRange.start, framingRange.end, true)
.filter(date => date.valueOf() < framingRange.end.valueOf())
}
}

}
Expand Down

0 comments on commit 6b525ec

Please sign in to comment.