diff --git a/website/common/script/cron.js b/website/common/script/cron.js index c07e666589..168a8cfe27 100644 --- a/website/common/script/cron.js +++ b/website/common/script/cron.js @@ -32,7 +32,7 @@ function sanitizeOptions (o) { let dayStart = !Number.isNaN(ref) && ref >= 0 && ref <= 24 ? ref : 0; let timezoneOffset; - let timezoneOffsetDefault = Number(moment().utcOffset()); + let timezoneOffsetDefault = Number(moment().zone()); if (isFinite(o.timezoneOffsetOverride)) { timezoneOffset = Number(o.timezoneOffsetOverride); } else if (Number.isFinite(o.timezoneOffset)) { @@ -45,7 +45,7 @@ function sanitizeOptions (o) { timezoneOffset = timezoneOffsetDefault; } - let now = o.now ? moment(o.now).utcOffset(timezoneOffset) : moment().utcOffset(timezoneOffset); + let now = o.now ? moment(o.now).zone(timezoneOffset) : moment().zone(timezoneOffset); // return a new object, we don't want to add "now" to user object return { @@ -101,7 +101,7 @@ export function shouldDo (day, dailyTask, options = {}) { // The time portion of the Start Date is never visible to or modifiable by the user so we must ignore it. // Therefore, we must also ignore the time portion of the user's day start (startOfDayWithCDSTime), otherwise the date comparison will be wrong for some times. // NB: The user's day start date has already been converted to the PREVIOUS day's date if the time portion was before CDS. - let startDate = moment(dailyTask.startDate).utcOffset(o.timezoneOffset).startOf('day'); + let startDate = moment(dailyTask.startDate).zone(o.timezoneOffset).startOf('day'); if (startDate > startOfDayWithCDSTime.startOf('day')) { return false; // Daily starts in the future