Skip to content

Commit

Permalink
add failing tests. revert functionality of PR #5326
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jul 29, 2020
1 parent 480188e commit 9b5a9ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
17 changes: 16 additions & 1 deletion packages/__tests__/src/datelib/rrule.js
Expand Up @@ -225,7 +225,7 @@ describe('rrule plugin', function() {
expect(events[0].extendedProps).toEqual({}) // didnt accumulate allDay or rrule props
})

it('can expand monthly recurrence', function() {
it('can expand monthly recurrence in UTC', function() {
initCalendar({
initialView: 'dayGridMonth',
now: '2018-12-25T12:00:00',
Expand All @@ -239,6 +239,21 @@ describe('rrule plugin', function() {
expect(events[0].start).toEqualDate('2018-12-13')
})

it('can expand monthly recurrence in local timeZone', function() {
initCalendar({
initialView: 'dayGridMonth',
now: '2018-12-25T12:00:00',
timeZone: 'local',
events: [ {
rrule: 'DTSTART:20181101\nRRULE:FREQ=MONTHLY;COUNT=13;BYMONTHDAY=13'
} ]
})

let events = currentCalendar.getEvents()
expect(events.length).toBe(1)
expect(events[0].start).toEqualLocalDate('2018-12-13')
})

it('can generate local dates', function() {
let localStart = buildLocalRRuleDateStr('2018-09-04T05:00:00')

Expand Down
14 changes: 3 additions & 11 deletions packages/rrule/src/main.ts
Expand Up @@ -30,18 +30,12 @@ let recurring: RecurringType<RRule> = {
return null
},

expand(rrule: RRule, framingRange: DateRange, dateEnv: DateEnv): DateMarker[] {
expand(rrule: RRule, framingRange: DateRange): 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.
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())
}
return rrule.between(framingRange.start, framingRange.end, true)
.filter(date => date.valueOf() < framingRange.end.valueOf())
}

}
Expand All @@ -59,7 +53,6 @@ function parseRRule(input, dateEnv: DateEnv) {

if (typeof input === 'string') {
rrule = rrulestr(input)
rrule.fromString = true

} else if (typeof input === 'object' && input) { // non-null object
let refined = { ...input } // copy
Expand Down Expand Up @@ -94,7 +87,6 @@ function parseRRule(input, dateEnv: DateEnv) {
}

rrule = new RRule(refined)
rrule.fromString = false
}

if (rrule) {
Expand Down

0 comments on commit 9b5a9ad

Please sign in to comment.