Skip to content

Commit

Permalink
helpers: Update datetime function
Browse files Browse the repository at this point in the history
Remove the process.env.TZ check - we explicitly set this
Add a comment about setting this value
  • Loading branch information
Jared Parnell committed Apr 8, 2021
1 parent ac3566e commit dc3ee61
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/helpers/datetime-helper.js
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down

0 comments on commit dc3ee61

Please sign in to comment.