mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Moved back to zone function
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user