Skip to content

Commit dc3ee61

Browse files
author
Jared Parnell
committed
helpers: Update datetime function
Remove the process.env.TZ check - we explicitly set this Add a comment about setting this value
1 parent ac3566e commit dc3ee61

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/helpers/datetime-helper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const { DateTime } = require('luxon');
22

33
function getDateTime(ianaTimezone, dateString, timeString) {
4+
// Node pulls the timezone from the system on initialisation using the TZ environment variable.
5+
// We can change process.env.TZ to UTC. This will update the current Node process.
46
process.env.TZ = 'UTC';
5-
if (process.env.TZ !== 'UTC') {
6-
throw new Error(`Schedule generation logic relies on 'TZ' env var being set to 'UTC'. It is currently: ${process.env.TZ}`);
7-
}
87
if (typeof dateString !== 'undefined' && typeof timeString !== 'undefined') {
98
return DateTime.fromISO(`${dateString}T${timeString}`, { zone: ianaTimezone }).toJSDate();
109
}

0 commit comments

Comments
 (0)