Moved back to zone function

This commit is contained in:
Keith Holliday
2017-05-10 15:47:32 -06:00
parent 76222ac344
commit 59fb32ea2e

View File

@@ -32,7 +32,7 @@ function sanitizeOptions (o) {
let dayStart = !Number.isNaN(ref) && ref >= 0 && ref <= 24 ? ref : 0; let dayStart = !Number.isNaN(ref) && ref >= 0 && ref <= 24 ? ref : 0;
let timezoneOffset; let timezoneOffset;
let timezoneOffsetDefault = Number(moment().utcOffset()); let timezoneOffsetDefault = Number(moment().zone());
if (isFinite(o.timezoneOffsetOverride)) { if (isFinite(o.timezoneOffsetOverride)) {
timezoneOffset = Number(o.timezoneOffsetOverride); timezoneOffset = Number(o.timezoneOffsetOverride);
} else if (Number.isFinite(o.timezoneOffset)) { } else if (Number.isFinite(o.timezoneOffset)) {
@@ -45,7 +45,7 @@ function sanitizeOptions (o) {
timezoneOffset = timezoneOffsetDefault; 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 a new object, we don't want to add "now" to user object
return { 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. // 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. // 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. // 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')) { if (startDate > startOfDayWithCDSTime.startOf('day')) {
return false; // Daily starts in the future return false; // Daily starts in the future