Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Commands/CreateOrEditTaskParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TasksFile } from '../Scripting/TasksFile';
import { Status } from '../Statuses/Status';
import { OnCompletion } from '../Task/OnCompletion';
import { Task } from '../Task/Task';
import { momentAdjusted } from '../DateTime/DateAdjusted';
import { DateFallback } from '../DateTime/DateFallback';
import { StatusRegistry } from '../Statuses/StatusRegistry';
import { TaskLocation } from '../Task/TaskLocation';
Expand All @@ -12,7 +13,7 @@ import { TaskRegularExpressions } from '../Task/TaskRegularExpressions';

function getDefaultCreatedDate() {
const { setCreatedDate } = getSettings();
return setCreatedDate ? window.moment() : null;
return setCreatedDate ? momentAdjusted() : null;
}

function shouldUpdateCreatedDateForTask(task: Task) {
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface Settings {
setCreatedDate: boolean;
setDoneDate: boolean;
setCancelledDate: boolean;
nextDayStartHour: number;
autoSuggestInEditor: boolean;
autoSuggestMinMatch: number;
autoSuggestMaxItems: number;
Expand Down Expand Up @@ -106,6 +107,7 @@ const defaultSettings: Readonly<Settings> = {
setCreatedDate: false,
setDoneDate: true,
setCancelledDate: true,
nextDayStartHour: 0,
autoSuggestInEditor: true,
autoSuggestMinMatch: 0,
autoSuggestMaxItems: 20,
Expand Down
22 changes: 22 additions & 0 deletions src/Config/SettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,28 @@ export class SettingsTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName(i18n.t('settings.dates.nextDayStartHour.name'))
.setDesc(
SettingsTab.createFragmentWithHTML(
i18n.t('settings.dates.nextDayStartHour.description') +
'</br>' +
this.seeTheDocumentation(
'https://publish.obsidian.md/tasks/Getting+Started/Dates#Next+day+start+at',
),
),
)
.addSlider((slider) => {
const settings = getSettings();
slider.setLimits(0, 23, 1);
Comment on lines +348 to +350
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find the slider UI very intuitive, although that is mainly an Obsidian thing, rather than specific to Tasks.

Please have a think about whether the (recently-added) RESTART REQUIRED label will be required on this, for now. Like, will search queries need to be re-triggered if the setting is changed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Adding "RESTART REQUIRED" would be necessary. Queries would only need to retrigger if current local time is between nextDayStartHour_OLD:00 and nextDayStartHour_NEW:00 (or reverse) though.

I don't think anyone will change this setting often, this is a 'set to 4AM and forget' feature. Anki uses 4AM as default and I don't think many users ever change it. Of course, we'd want to keep 0 as default to preserve backwards compatibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this setting relate to the user's time zone, if at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't. It should only look at local time value.

slider.setValue(settings.nextDayStartHour);
slider.setDynamicTooltip();
slider.onChange(async (value) => {
updateSettings({ nextDayStartHour: value });
await this.plugin.saveSettings();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What impact will this feature have on the "Reload the vault at midnight" facility in Tasks?

The idea of that feature is that all queries are reloaded a few seconds after midnight, so that things like "due today" are re-interpreted with the new date.

Except that with this feature set to +2, the reload at midnight will have no effect...

And instead presumably the queries should all be reloaded at a few seconds after 2am instead - but for now, users will need to know to do that themselves manually.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the only problem I foresaw. I guess there are two options.

  1. Change now.subtract(1, 'day').endOf('day'); to now.subtract(nextDayStartHour, 'hours');
    This would mean that reloadQueryAtMidnight would run at true midnight (uselessly) and then again nextDayStartHour hours later. Perhaps the best option would be to just do now.subtract(nextDayStartHour, 'hours'); for all calls to this function. If nextDayStartHour = 0, nothing happens. Otherwise, we preserve the continuity of time if any caller is actually interested in that.

  2. Keep now.subtract(1, 'day').endOf('day'); but make reloadQueryAtMidnight aware of nextDayStartHour setting.
    I'd really wanted to evade this and make as few external procedures aware of the setting.

});
});

// ---------------------------------------------------------------------------
new Setting(containerEl).setName(i18n.t('settings.datesFromFileNames.heading')).setHeading();
// ---------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions src/DateTime/DateAdjusted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Moment } from "moment";
import { getSettings } from "../Config/Settings";

/**
* Returns the current moment, adjusted for the "Next day start hour" setting.
*
* If the current time is before the "next day start hour" (e.g., 2 AM),
* this function will return a moment object for the end of the *previous* day.
* Otherwise, it returns the current, unaltered moment.
*/
export function momentAdjusted(): Moment {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There really needs to be tests for this, and updated versions of the existing tests for features that have been modified in this PR - to demonstrate how the behaviour has changed.

For example, demonstration of how this feature interacts in time-zones other than GMT... (I haven't yet been able to get my head around that)

const { nextDayStartHour } = getSettings();
const now = window.moment();
if (now.hour() < nextDayStartHour) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when clocks change? There needs to be tests for this - including in timezones close to the international date line...

I have written up the results of my previous experiments in timezones in tests:

https://publish.obsidian.md/tasks-contributing/Testing/Testing+and+Time+Zones

return now.subtract(1, 'day').endOf('day');
}
return now;
}
5 changes: 3 additions & 2 deletions src/DateTime/DateRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Moment } from 'moment';
import { momentAdjusted } from './DateAdjusted';

/**
* Represent an inclusive span of time between two days at 00:00 local time.
Expand Down Expand Up @@ -41,8 +42,8 @@ export class DateRange {
const unitOfTime = range === 'week' ? 'isoWeek' : range;

return new DateRange(
window.moment().startOf(unitOfTime).startOf('day'),
window.moment().endOf(unitOfTime).startOf('day'),
momentAdjusted().startOf(unitOfTime).startOf('day'),
momentAdjusted().endOf(unitOfTime).startOf('day'),
Comment on lines +45 to +46
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintenance-wise, I think this PR is going to be a bit fragile over time.

  • It is repetitious
  • Every person who works on this code in future is going to have to know that they mustn't use window.moment() directly.
  • And/or every reviewer is going to have to remember to look out for window.moment() uses

I started rolling out a TasksDate but unfortunately not managed to make time on fully adopting it to replace all storage and direct access to moment objects.

Too much is in my head only, currently, about what needs to be done to finish adopting it...

I am not totally opposed to the approach in this PR, but personally, I would have imagined that standardising time-and-date storage and access would be a preferable first step, before implementing this feature.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think whatever method we use there'd be potential to not respect user's setting of nextDayStartHour (unless we centralize time source). Personally, I think that just adding a note in "Using Moment as a type in src/" should be enough. That's one of the first entries I read before typing moment anywhere so I think it's prominent enough.

I agree that centralized TasksDate would be ideal but perhaps this is already a turn in that direction? We'd have centralized momentAdjusted (or some other name) procedure which could later just be replaced with TasksDate version.

);
}

Expand Down
5 changes: 3 additions & 2 deletions src/DateTime/DateTools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as chrono from 'chrono-node';
import { momentAdjusted } from './DateAdjusted';

export function compareByDate(a: moment.Moment | null, b: moment.Moment | null): -1 | 0 | 1 {
if (a !== null && b === null) {
Expand Down Expand Up @@ -77,7 +78,7 @@ export function parseTypedDateForDisplayUsingFutureDate(
typedDate: string,
forwardOnly: boolean,
): string {
return parseTypedDateForDisplay(fieldName, typedDate, forwardOnly ? new Date() : undefined);
return parseTypedDateForDisplay(fieldName, typedDate, forwardOnly ? momentAdjusted().toDate() : undefined);
}

/**
Expand All @@ -87,7 +88,7 @@ export function parseTypedDateForDisplayUsingFutureDate(
*/
export function parseTypedDateForSaving(typedDate: string, forwardDate: boolean): moment.Moment | null {
let date: moment.Moment | null = null;
const parsedDate = chrono.parseDate(typedDate, new Date(), { forwardDate });
const parsedDate = chrono.parseDate(typedDate, momentAdjusted().toDate(), { forwardDate });
if (parsedDate !== null) {
date = window.moment(parsedDate);
}
Expand Down
7 changes: 4 additions & 3 deletions src/DateTime/Postponer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Moment, unitOfTime } from 'moment';
import { capitalizeFirstLetter } from '../lib/StringHelpers';
import { Task } from '../Task/Task';
import { momentAdjusted } from './DateAdjusted';
import { DateFallback } from './DateFallback';
import { TasksDate } from './TasksDate';
import type { AllTaskDateFields, HappensDate } from './DateFieldTypes';
Expand Down Expand Up @@ -81,7 +82,7 @@ export function createFixedDateTask(
timeUnit: unitOfTime.DurationConstructor,
amount: number,
) {
const dateToPostpone = window.moment();
const dateToPostpone = momentAdjusted();
return createPostponedTaskFromDate(dateToPostpone, task, dateFieldToPostpone, timeUnit, amount);
}

Expand Down Expand Up @@ -164,7 +165,7 @@ export function postponeMenuItemTitle(task: Task, amount: number, timeUnit: unit
*/
export function fixedDateMenuItemTitle(task: Task, amount: number, timeUnit: unitOfTime.DurationConstructor) {
const updatedDateType = getDateFieldToPostpone(task)!;
const dateToUpdate = window.moment().startOf('day');
const dateToUpdate = momentAdjusted().startOf('day');
return postponeMenuItemTitleFromDate(updatedDateType, dateToUpdate, amount, timeUnit);
}

Expand Down Expand Up @@ -207,7 +208,7 @@ export function postponeMenuItemTitleFromDate(
const formattedNewDate = postponedDate.format('ddd Do MMM');

const amountOrArticle = amount != 1 ? amount : 'a';
if (dateToUpdate.isSameOrBefore(window.moment(), 'day')) {
if (dateToUpdate.isSameOrBefore(momentAdjusted(), 'day')) {
const updatedDateDisplayText = prettyPrintDateFieldName(updatedDateType);
const title =
amount >= 0
Expand Down
7 changes: 4 additions & 3 deletions src/DateTime/TasksDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { DurationInputArg2, Moment, unitOfTime } from 'moment';
import { Notice } from 'obsidian';
import { PropertyCategory } from '../lib/PropertyCategory';
import { TaskRegularExpressions } from '../Task/TaskRegularExpressions';
import { momentAdjusted } from './DateAdjusted';

/**
* TasksDate encapsulates a date, for simplifying the JavaScript expressions users need to
Expand Down Expand Up @@ -59,7 +60,7 @@ export class TasksDate {

public get category(): PropertyCategory {
// begin-snippet: use-moment-in-src
const today = window.moment();
const today = momentAdjusted();
// end-snippet
const date = this.moment;
if (!date) {
Expand Down Expand Up @@ -96,7 +97,7 @@ export class TasksDate {
// - is the same for all dates with the same 'fromNow()' name,
// - sorts in ascending order of the date.

const now = window.moment();
const now = momentAdjusted();
const earlier = date.isSameOrBefore(now, 'day');
const startDateOfThisGroup = this.fromNowStartDateOfGroup(date, earlier, now);
const splitPastAndFutureDates = earlier ? 1 : 3;
Expand Down Expand Up @@ -124,7 +125,7 @@ export class TasksDate {
public postpone(unitOfTime: unitOfTime.DurationConstructor = 'days', amount: number = 1) {
if (!this._date) throw new Notice('Cannot postpone a null date');

const today = window.moment().startOf('day');
const today = momentAdjusted().startOf('day');
// According to the moment.js docs, isBefore is not stable so we use !isSameOrAfter: https://momentjs.com/docs/#/query/is-before/
const isDateBeforeToday = !this._date.isSameOrAfter(today, 'day');

Expand Down
8 changes: 4 additions & 4 deletions src/Renderer/QueryRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getTaskLineAndFile, replaceTaskWithTasks } from '../Obsidian/File';
import { TaskModal } from '../Obsidian/TaskModal';
import type { TasksEvents } from '../Obsidian/TasksEvents';
import { TasksFile } from '../Scripting/TasksFile';
import { momentAdjusted } from '../DateTime/DateAdjusted';
import { DateFallback } from '../DateTime/DateFallback';
import type { Task } from '../Task/Task';
import { type BacklinksEventHandler, type EditButtonClickHandler, QueryResultsRenderer } from './QueryResultsRenderer';
Expand Down Expand Up @@ -257,11 +258,10 @@ class QueryRenderChild extends MarkdownRenderChild {
* to "now".
*/
private reloadQueryAtMidnight(): void {
const midnight = new Date();
midnight.setHours(24, 0, 0, 0);
const now = new Date();
const midnight = momentAdjusted().add(1, 'days').startOf('day');
const now = momentAdjusted();

const millisecondsToMidnight = midnight.getTime() - now.getTime();
const millisecondsToMidnight = midnight.diff(now, 'milliseconds');

this.queryReloadTimeout = setTimeout(() => {
this.queryResultsRenderer.query = getQueryForQueryRenderer(
Expand Down
3 changes: 2 additions & 1 deletion src/Renderer/TaskFieldRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Moment } from 'moment';
import type { TaskLayoutComponent } from '../Layout/TaskLayoutOptions';
import { PriorityTools } from '../lib/PriorityTools';
import type { Task } from '../Task/Task';
import { momentAdjusted } from '../DateTime/DateAdjusted';

/**
* A renderer for individual {@link Task} fields in an HTML context.
Expand Down Expand Up @@ -67,7 +68,7 @@ export class TaskFieldHTMLData {
const DAY_VALUE_OVER_RANGE_POSTFIX = 'far';

function dateToAttribute(date: Moment) {
const today = window.moment().startOf('day');
const today = momentAdjusted().startOf('day');
const diffDays = today.diff(date, 'days');

if (isNaN(diffDays)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Renderer/TaskLineRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { StatusRegistry } from '../Statuses/StatusRegistry';
import { Task } from '../Task/Task';
import { TaskRegularExpressions } from '../Task/TaskRegularExpressions';
import { StatusMenu } from '../ui/Menus/StatusMenu';
import { momentAdjusted } from '../DateTime/DateAdjusted';
import type { AllTaskDateFields } from '../DateTime/DateFieldTypes';
import { defaultTaskSaver, showMenu } from '../ui/Menus/TaskEditingMenu';
import { promptForDate } from '../ui/Menus/DatePicker';
Expand Down Expand Up @@ -430,7 +431,7 @@ export class TaskLineRenderer {

function toTooltipDate({ signifier, date }: { signifier: string; date: Moment }): string {
return `${signifier} ${date.format(TaskRegularExpressions.dateFormat)} (${date.from(
window.moment().startOf('day'),
momentAdjusted().startOf('day'),
)})`;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Task/Recurrence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Moment } from 'moment';
// end-snippet
import { RRule } from 'rrule';
import type { Occurrence } from './Occurrence';
import { momentAdjusted } from '../DateTime/DateAdjusted';

export class Recurrence {
private readonly rrule: RRule;
Expand Down Expand Up @@ -38,7 +39,7 @@ export class Recurrence {
if (!baseOnToday && referenceDate !== null) {
options.dtstart = window.moment(referenceDate).startOf('day').utc(true).toDate();
} else {
options.dtstart = window.moment().startOf('day').utc(true).toDate();
options.dtstart = momentAdjusted().startOf('day').utc(true).toDate();
}

const rrule = new RRule(options);
Expand Down Expand Up @@ -73,7 +74,7 @@ export class Recurrence {
*
* @param today - Optional date representing the completion date. Defaults to today.
*/
public next(today = window.moment()): Occurrence | null {
public next(today = momentAdjusted()): Occurrence | null {
const nextReferenceDate = this.nextReferenceDate(today);

if (nextReferenceDate === null) {
Expand Down
7 changes: 4 additions & 3 deletions src/Task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { StatusType } from '../Statuses/StatusConfiguration';
import { PriorityTools } from '../lib/PriorityTools';
import { logging } from '../lib/logging';
import { logEndOfTaskEdit, logStartOfTaskEdit } from '../lib/LogTasksHelper';
import { momentAdjusted } from '../DateTime/DateAdjusted';
import { DateFallback } from '../DateTime/DateFallback';
import { ListItem } from './ListItem';
import type { Occurrence } from './Occurrence';
Expand Down Expand Up @@ -343,7 +344,7 @@ export class Task extends ListItem {
* However, any created date on a new recurrence is, for now, calculated from the
* actual current date, rather than this parameter.
*/
public handleNewStatus(newStatus: Status, today = window.moment()): Task[] {
public handleNewStatus(newStatus: Status, today = momentAdjusted()): Task[] {
if (newStatus.identicalTo(this.status)) {
// There is no need to create a new Task object if the new status behaviour is identical to the current one.
return [this];
Expand Down Expand Up @@ -419,7 +420,7 @@ export class Task extends ListItem {
const { setCreatedDate } = getSettings();
let createdDate: moment.Moment | null = null;
if (setCreatedDate) {
createdDate = window.moment();
createdDate = momentAdjusted();
}
// In case the task being toggled was previously cancelled, ensure the new task has no cancelled date:
const cancelledDate = null;
Expand Down Expand Up @@ -471,7 +472,7 @@ export class Task extends ListItem {
return this.putRecurrenceInUsersOrder(newTasks);
}

public handleNewStatusWithRecurrenceInUsersOrder(newStatus: Status, today = window.moment()): Task[] {
public handleNewStatusWithRecurrenceInUsersOrder(newStatus: Status, today = momentAdjusted()): Task[] {
const logger = logging.getLogger('tasks.Task');
logger.debug(
`changed task ${this.taskLocation.path} ${this.taskLocation.lineNumber} ${this.originalMarkdown} status to '${newStatus.symbol}'`,
Expand Down
7 changes: 4 additions & 3 deletions src/Task/Urgency.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { momentAdjusted } from '../DateTime/DateAdjusted';
import type { Task } from './Task';

export class Urgency {
Expand All @@ -13,7 +14,7 @@ export class Urgency {

if (task.dueDate?.isValid()) {
// Map a range of 21 days to the value 0.2 - 1.0
const startOfToday = window.moment().startOf('day');
const startOfToday = momentAdjusted().startOf('day');
const daysOverdue = Math.round(startOfToday.diff(task.dueDate) / Urgency.milliSecondsPerDay);

let dueMultiplier: number;
Expand All @@ -30,13 +31,13 @@ export class Urgency {
}

if (task.scheduledDate?.isValid()) {
if (window.moment().isSameOrAfter(task.scheduledDate)) {
if (momentAdjusted().isSameOrAfter(task.scheduledDate)) {
urgency += 1 * Urgency.scheduledCoefficient;
}
}

if (task.startDate?.isValid()) {
if (window.moment().isBefore(task.startDate)) {
if (momentAdjusted().isBefore(task.startDate)) {
urgency += 1 * Urgency.startedCoefficient;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
},
"changeRequiresRestart": "REQUIRES RESTART.",
"dates": {
"nextDayStartHour": {
"description": "Sets the hour at which the new day begins. Interacting with tasks after midnight but before this hour is treated as if interacting the day before.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could it expand on what it means by "interacting"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to emphasize "all interactions with obsidian-tasks plugin", i.e. "all responses-to-user-action ...". Meaning that, yes, completing tasks "is treated as if interacting the day before", but also so is using the "td"/"tm" shortcuts, playing with datetime picker, etc.

"name": "Next day starts at"
},
"cancelledDate": {
"description": "Enabling this will add a timestamp ❌ YYYY-MM-DD at the end when a task is toggled to cancelled.",
"name": "Set cancelled date on every cancelled task"
Expand Down
5 changes: 3 additions & 2 deletions src/ui/EditInstructions/DateInstructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { unitOfTime } from 'moment';
import type { AllTaskDateFields } from '../../DateTime/DateFieldTypes';
import { Task } from '../../Task/Task';
import { postponeMenuItemTitleFromDate, removeDateMenuItemTitleForField } from '../../DateTime/Postponer';
import { momentAdjusted } from '../../DateTime/DateAdjusted';
import { TasksDate } from '../../DateTime/TasksDate';
import type { TaskEditingInstruction } from './TaskEditingInstruction';
import { MenuDividerInstruction } from './MenuDividerInstruction';
Expand Down Expand Up @@ -57,7 +58,7 @@ export class SetRelativeTaskDate extends SetTaskDate {
amount: number,
timeUnit: unitOfTime.DurationConstructor,
) {
const currentDate = taskDueToday[dateFieldToEdit] ?? window.moment();
const currentDate = taskDueToday[dateFieldToEdit] ?? momentAdjusted();
const title = postponeMenuItemTitleFromDate(dateFieldToEdit, currentDate, amount, timeUnit);

const newDate = new TasksDate(window.moment(currentDate)).postpone(timeUnit, amount).toDate();
Expand Down Expand Up @@ -132,7 +133,7 @@ export function allLifeCycleDateInstructions(field: AllTaskDateFields, task: Tas
* @param factor - +1 means today or future dates; -1 = today or earlier dates.
*/
function allDateInstructions(task: Task, field: AllTaskDateFields, factor: number) {
const today = window.moment().startOf('day');
const today = momentAdjusted().startOf('day');
const todayAsDate = today.toDate();
const todayAsTasksDate = new TasksDate(today.clone());

Expand Down
3 changes: 2 additions & 1 deletion src/ui/EditableTask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GlobalFilter } from '../Config/GlobalFilter';
import { momentAdjusted } from '../DateTime/DateAdjusted';
import { parseTypedDateForSaving } from '../DateTime/DateTools';
import { PriorityTools } from '../lib/PriorityTools';
import { replaceTaskWithTasks } from '../Obsidian/File';
Expand Down Expand Up @@ -252,7 +253,7 @@ export class EditableTask {
}

// Otherwise, use the current date.
return window.moment();
return momentAdjusted();
}

public parseAndValidateRecurrence() {
Expand Down
Loading