From b883fae591882df6f877f7d277ccf7481ecb52f6 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Mon, 3 Aug 2020 09:15:35 -0400 Subject: [PATCH] capitalize byDay even when bySetPos is used --- README.md | 2 +- src/event.js | 2 +- test/test_event.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4b49b792b..3a59245c1 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/event.js b/src/event.js index 88dd9530b..81214d340 100755 --- a/src/event.js +++ b/src/event.js @@ -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; } diff --git a/test/test_event.js b/test/test_event.js index 346a079cd..7a492943d 100644 --- a/test/test_event.js +++ b/test/test_event.js @@ -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); });