From e23459fa033a3cc45ac25178669434d69adc1051 Mon Sep 17 00:00:00 2001 From: Jonas Braathen Date: Mon, 27 Apr 2020 23:30:03 +0200 Subject: [PATCH] Another attempt at working around DST issues --- src/templates/event.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/templates/event.js b/src/templates/event.js index 5a8bcd5..bc7ec65 100644 --- a/src/templates/event.js +++ b/src/templates/event.js @@ -52,7 +52,22 @@ export const EventTemplate = ({ }) => { const hasFeaturedMedia = featuredMedia && !!featuredMedia.localFile /* TODO: Make API return proper UTC datetimes */ - const start = moment(startTime).utcOffset(1) + const startTimeNaive = startTime.replace("+00:00", "") + const endTimeNaive = endTime && endTime.replace("+00:00", "") + /* + const dst = moment(startTimeNaive).isDST() + const utcOffset = dst ? 2 : 2 + */ + /* looks like whatever we get above is always two hours behind! maybe. + at least this is true *now* if dst is true or false + did removing the TZ info from the string help? + */ + /* TODO: does this change with server time when DST toggles? + if so, see you in October + */ + const utcOffset = 2; + const start = moment.utc(startTimeNaive).utcOffset(utcOffset) + const end = endTimeNaive && moment.utc(endTimeNaive).utcOffset(utcOffset) return (
@@ -92,7 +107,7 @@ export const EventTemplate = ({
{/* TODO: make the API stop assuming event duration is 2 hours when unspecified? */} kl. {start.format('HH:mm')} - {endTime && <>—{moment(endTime).utcOffset(1).format('HH:mm')}} + {end && <>—{end.format('HH:mm')}}
Pris: {formatPrices(priceRegular, priceStudent)}