Make start date and day of month aware of timezones (fixes #12555) (#12696)

* WIP: #12555

-dayOfMonth takes timezone into account on task update for monthly dailys
-startDate set to start of day in user's tz on task update for monthly
dailys
-tweaked a test so that it's actually testing something

* WIP: 12555

-task.startDate gets set to start of day in user's tz on task creation
and task update
-set preferences.timezoneOffset to nonzero value in certian test user objects
-removed date literals in test:api-v3:integration:tasks:PUT
This commit is contained in:
bakerty
2021-01-10 07:02:40 -08:00
committed by GitHub
parent e8d3090a99
commit db3d233ae5
8 changed files with 83 additions and 29 deletions

View File

@@ -124,6 +124,15 @@ export async function createTasks (req, res, options = {}) {
}
}
// set startDate to midnight in the user's timezone
if (taskType === 'daily') {
const awareStartDate = moment(newTask.startDate).utcOffset(-user.preferences.timezoneOffset);
if (awareStartDate.format('HMsS') !== '0000') {
awareStartDate.startOf('day');
newTask.startDate = awareStartDate.toDate();
}
}
setNextDue(newTask, user);
// Validate that the task is valid and throw if it isn't