Skip to content

Commit

Permalink
fix(Tools): Prevent formatDate() from using global timezones prefixed…
Browse files Browse the repository at this point in the history
… with a slash
  • Loading branch information
sebbo2002 committed Apr 14, 2021
1 parent f5d9eb3 commit 85ab7b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export default class ICalCalendar {
*
* @since 2.0.0
*/
timezone(timezone: ICalTimezone): this;
timezone(timezone: ICalTimezone | string | null): this;
timezone(timezone?: ICalTimezone | string | null): this | string | null {
if (timezone === undefined) {
return this.data.timezone?.name || null;
Expand Down
4 changes: 4 additions & 0 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import type { RRule } from 'rrule';
import {ICalDateTimeValue, ICalOrganizer} from './types';

export function formatDate (timezone: string | null, d: ICalDateTimeValue, dateonly?: boolean, floating?: boolean): string {
if(timezone?.startsWith('/')) {
timezone = timezone.substr(1);
}

if(typeof d === 'string' || d instanceof Date) {
const m = new Date(d);

Expand Down

0 comments on commit 85ab7b2

Please sign in to comment.