From dc3ee6139fbe39a657eccf0fd0aaa413c153fff7 Mon Sep 17 00:00:00 2001 From: Jared Parnell Date: Thu, 8 Apr 2021 17:13:59 +0100 Subject: [PATCH] helpers: Update datetime function Remove the process.env.TZ check - we explicitly set this Add a comment about setting this value --- src/helpers/datetime-helper.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/helpers/datetime-helper.js b/src/helpers/datetime-helper.js index c8fc50a..206aa99 100644 --- a/src/helpers/datetime-helper.js +++ b/src/helpers/datetime-helper.js @@ -1,10 +1,9 @@ const { DateTime } = require('luxon'); function getDateTime(ianaTimezone, dateString, timeString) { + // Node pulls the timezone from the system on initialisation using the TZ environment variable. + // We can change process.env.TZ to UTC. This will update the current Node process. process.env.TZ = 'UTC'; - if (process.env.TZ !== 'UTC') { - throw new Error(`Schedule generation logic relies on 'TZ' env var being set to 'UTC'. It is currently: ${process.env.TZ}`); - } if (typeof dateString !== 'undefined' && typeof timeString !== 'undefined') { return DateTime.fromISO(`${dateString}T${timeString}`, { zone: ianaTimezone }).toJSDate(); }