diff --git a/src/components/Event.tsx b/src/components/Event.tsx index 32d6379..f5846ba 100644 --- a/src/components/Event.tsx +++ b/src/components/Event.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import PimItemHeader from './PimItemHeader'; -import { formatDateRange } from '../helpers'; +import { formatDateRange, formatOurTimezoneOffset } from '../helpers'; import { EventType } from '../pim-types'; @@ -27,7 +27,7 @@ class Event extends React.PureComponent { return ( -
{formatDateRange(this.props.item.startDate, this.props.item.endDate)} {timezone && ({timezone})}
+
{formatDateRange(this.props.item.startDate, this.props.item.endDate)} {timezone && ({formatOurTimezoneOffset()})}

{this.props.item.location}
diff --git a/src/components/Task.tsx b/src/components/Task.tsx index f05eca5..d9abbb2 100644 --- a/src/components/Task.tsx +++ b/src/components/Task.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import PimItemHeader from './PimItemHeader'; -import { formatDate } from '../helpers'; +import { formatDate, formatOurTimezoneOffset } from '../helpers'; import { TaskType } from '../pim-types'; @@ -30,10 +30,10 @@ class Task extends React.PureComponent { {item.startDate && -
Start: {formatDate(item.startDate)} {timezone && ({timezone})}
+
Start: {formatDate(item.startDate)} {timezone && ({formatOurTimezoneOffset()})}
} {item.dueDate && -
Due: {formatDate(item.dueDate)} {timezone && ({timezone})}
+
Due: {formatDate(item.dueDate)} {timezone && ({formatOurTimezoneOffset()})}
}
{this.props.item.location}
diff --git a/src/helpers.tsx b/src/helpers.tsx index 6135480..28de623 100644 --- a/src/helpers.tsx +++ b/src/helpers.tsx @@ -90,3 +90,13 @@ export function formatDateRange(start: ICAL.Time, end: ICAL.Time) { return strStart + ' - ' + strEnd; } + +export function formatOurTimezoneOffset() { + let offset = new Date().getTimezoneOffset(); + const prefix = (offset > 0) ? '-' : '+'; + offset = Math.abs(offset); + const hours = Math.floor(offset / 60); + const minutes = offset % 60; + + return `GMT${prefix}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`; +}