Skip to content

Commit

Permalink
feat(Events): use provided timezone when constructing repeating.exclu…
Browse files Browse the repository at this point in the history
…de (#210)

* use provided timezone when constructing repeating.exclude

* tests for issue #210

* fix indentation
  • Loading branch information
rubys committed Aug 18, 2020
1 parent 10327ac commit bd84230
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,12 @@ class ICalEvent {
c._data.repeating.exclude = [];
exclude.forEach(function (excludedDate, i) {
if (typeof excludedDate === 'string') {
excludedDate = moment(excludedDate);
let timezone = repeating.excludeTimezone || c._calendar._data.timezone;
if (timezone) {
excludedDate = moment.tz(excludedDate, timezone);
} else {
excludedDate = moment(excludedDate);
}
}
else if (excludedDate instanceof Date) {
excludedDate = moment(excludedDate);
Expand Down
43 changes: 43 additions & 0 deletions test/test_issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,47 @@ describe('Issues', function () {
});
});
});

describe('Issue #210', function () {
it('should repeat/exclude with Europe/Berlin', function () {
const calendar = ical({
domain: 'sebbo.net',
prodId: '//superman-industries.com//ical-generator//EN',
timezone: 'Europe/Berlin',
events: [{
start: '2020-08-13T00:00:00',
summary: 'Example Event',
repeating: {
freq: 'MONTHLY',
count: 12,
exclude: '2020-12-13T00:00:00',
excludeTimezone: 'Europe/Berlin'
}
}]
});

const str = calendar.toString();
assert.ok(str.indexOf('EXDATE;TZID=Europe/Berlin:20201213T000000') > -1);
});
it('should repeat/exclude with America/New_York', function () {
const calendar = ical({
domain: 'sebbo.net',
prodId: '//superman-industries.com//ical-generator//EN',
timezone: 'America/New_York',
events: [{
start: '2020-08-13T00:00:00',
summary: 'Example Event',
repeating: {
freq: 'MONTHLY',
count: 12,
exclude: '2020-12-13T00:00:00',
excludeTimezone: 'America/New_York',
}
}]
});

const str = calendar.toString();
assert.ok(str.indexOf('EXDATE;TZID=America/New_York:20201213T000000') > -1);
});
});
});

0 comments on commit bd84230

Please sign in to comment.