Skip to content

Commit

Permalink
fix: capitalize byDay even when bySetPos is used (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys authored Aug 6, 2020
1 parent 2405737 commit 5440fbc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ event.repeating({
interval: 2,
until: new Date('Jan 01 2014 00:00:00 UTC'),
byDay: ['su', 'mo'], // repeat only sunday and monday
byMonth: [1, 2], // repeat only in january und february,
byMonth: [1, 2], // repeat only in january and february,
byMonthDay: [1, 15], // repeat only on the 1st and 15th
bySetPos: 3, // repeat every 3rd sunday (will take the first element of the byDay array)
exclude: [new Date('Dec 25 2013 00:00:00 UTC')], // exclude these dates
Expand Down
2 changes: 1 addition & 1 deletion src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class ICalEvent {
throw '`repeating.bySetPos` contains invalid value `' + repeating.bySetPos + '`!';
}

c._data.repeating.byDay = [repeating.byDay[0]];
c._data.repeating.byDay.splice(1);
c._data.repeating.bySetPos = repeating.bySetPos;
}

Expand Down
3 changes: 2 additions & 1 deletion test/test_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ describe('ical-generator Event', function () {
it('setter should update repeating.bySetPos', function () {
const e = new ICalEvent(null, new ICalCalendar());

e.repeating({freq: 'monthly', byDay: ['SU'], bySetPos: 2});
e.repeating({freq: 'monthly', byDay: ['su'], bySetPos: 2});
assert.strictEqual(e._data.repeating.byDay[0], 'SU');
assert.strictEqual(e._data.repeating.bySetPos, 2);
});

Expand Down

0 comments on commit 5440fbc

Please sign in to comment.