Skip to content

Commit

Permalink
feat(Calendar): Handle timezone('UTC') correctly
Browse files Browse the repository at this point in the history
see #328
  • Loading branch information
sebbo2002 committed Nov 8, 2021
1 parent b3d62db commit c0745e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,14 @@ export default class ICalCalendar {
* Use this method to set your feed's timezone. Is used
* to fill `TIMEZONE-ID` and `X-WR-TIMEZONE` in your iCal export.
* Please not that all date values are treaded differently, if
* a timezone was set. See [[`formatDate`]] for details.
* a timezone was set. See [[`formatDate`]] for details. If no
* time zone is specified, all information is output as UTC.
*
* ```javascript
* cal.timezone('America/New_York');
* ```
*
* @see https://github.com/sebbo2002/ical-generator#-date-time--timezones
* @since 0.2.0
*/
timezone(timezone: string | null): this;
Expand Down Expand Up @@ -333,6 +335,7 @@ export default class ICalCalendar {
* });
* ```
*
* @see https://github.com/sebbo2002/ical-generator#-date-time--timezones
* @since 2.0.0
*/
timezone(timezone: ICalTimezone | string | null): this;
Expand All @@ -341,7 +344,10 @@ export default class ICalCalendar {
return this.data.timezone?.name || null;
}

if(typeof timezone === 'string') {
if(timezone === 'UTC') {
this.data.timezone = null;
}
else if(typeof timezone === 'string') {
this.data.timezone = {name: timezone};
}
else if(timezone === null) {
Expand Down

0 comments on commit c0745e5

Please sign in to comment.