mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
* 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:
@@ -678,18 +678,29 @@ api.updateTask = {
|
||||
task.group.managerNotes = sanitizedObj.managerNotes;
|
||||
}
|
||||
|
||||
// If the daily task was set to repeat monthly on a day of the month, and the start date was
|
||||
// updated, the task will then need to be updated to repeat on the same day of the month as the
|
||||
// new start date. For example, if the start date is updated to 7/2/2020, the daily should
|
||||
// repeat on the 2nd day of the month. It's possible that a task can repeat monthly on a
|
||||
// week of the month, in which case we won't update the repetition at all.
|
||||
if (
|
||||
task.type === 'daily'
|
||||
&& task.frequency === 'monthly'
|
||||
&& task.daysOfMonth.length
|
||||
&& task.startDate
|
||||
// For daily tasks, update start date based on timezone to maintain consistency
|
||||
if (task.type === 'daily'
|
||||
&& task.startDate
|
||||
) {
|
||||
task.daysOfMonth = [moment(task.startDate).date()];
|
||||
task.startDate = moment(task.startDate).utcOffset(
|
||||
-user.preferences.timezoneOffset,
|
||||
).startOf('day').toDate();
|
||||
|
||||
// If the daily task was set to repeat monthly on a day of the month, and the start date was
|
||||
// updated, the task will then need to be updated to repeat on the same day of the month as
|
||||
// the new start date. For example, if the start date is updated to 7/2/2020, the daily
|
||||
// should repeat on the 2nd day of the month. It's possible that a task can repeat monthly
|
||||
// on a week of the month, in which case we won't update the repetition at all.
|
||||
if (
|
||||
task.frequency === 'monthly'
|
||||
&& task.daysOfMonth.length
|
||||
) {
|
||||
// We also need to aware of the user's timezone. Start date is represented as UTC, so the
|
||||
// start date and day of month might be different
|
||||
task.daysOfMonth = [moment(task.startDate).utcOffset(
|
||||
-user.preferences.timezoneOffset,
|
||||
).date()];
|
||||
}
|
||||
}
|
||||
|
||||
setNextDue(task, user);
|
||||
|
||||
Reference in New Issue
Block a user