From 5237b14b744ec9753c5336d15bc9e5c2df40b6b4 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 15 Feb 2019 10:58:12 +0000 Subject: [PATCH] Event and task: show timezone information. First steps towards #29. --- src/components/Event.tsx | 4 +++- src/components/Task.tsx | 6 ++++-- src/pim-types.ts | 10 ++++++++++ src/types/ical.js.d.ts | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/components/Event.tsx b/src/components/Event.tsx index 3dd623b..f9aa5ea 100644 --- a/src/components/Event.tsx +++ b/src/components/Event.tsx @@ -22,10 +22,12 @@ class Event extends React.PureComponent { }, }; + const timezone = this.props.item.timezone; + return ( -
{formatDateRange(this.props.item.startDate, this.props.item.endDate)}
+
{formatDateRange(this.props.item.startDate, this.props.item.endDate)} { timezone && ({timezone})}

{this.props.item.location}
diff --git a/src/components/Task.tsx b/src/components/Task.tsx index 6c88c7d..41738e2 100644 --- a/src/components/Task.tsx +++ b/src/components/Task.tsx @@ -24,14 +24,16 @@ class Task extends React.PureComponent { }, }; + const timezone = this.props.item.timezone; + return ( { item.startDate && -
Start: {formatDate(item.startDate)}
+
Start: {formatDate(item.startDate)} { timezone && ({timezone})}
} { item.dueDate && -
Due: {formatDate(item.dueDate)}
+
Due: {formatDate(item.dueDate)} { timezone && ({timezone})}
}
{this.props.item.location}
diff --git a/src/pim-types.ts b/src/pim-types.ts index bb6fa98..d18a15f 100644 --- a/src/pim-types.ts +++ b/src/pim-types.ts @@ -17,6 +17,16 @@ export class EventType extends ICAL.Event implements PimType { return new EventType(comp.getFirstSubcomponent('vevent')); } + get timezone() { + if (this.startDate) { + return this.startDate.timezone; + } else if (this.endDate) { + return this.endDate.timezone; + } + + return null; + } + get title() { return this.summary; } diff --git a/src/types/ical.js.d.ts b/src/types/ical.js.d.ts index 922666d..3041a88 100644 --- a/src/types/ical.js.d.ts +++ b/src/types/ical.js.d.ts @@ -70,6 +70,8 @@ declare module 'ical.js' { class Time { isDate: boolean; + timezone: string; + zone: Timezone; static fromString(str: string): Time; static fromJSDate(aDate: Date | null, useUTC: boolean): Time; @@ -102,4 +104,11 @@ declare module 'ical.js' { next(): Time; } + + class Timezone { + static localTimezone: Timezone; + static convert_time(tt: Time, from_zone: Timezone, to_zone: Timezone): Time; + + tzid: string; + } }