Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/recurrence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
hasTimeComponent,
parseDateToLocal,
parseDateToUTC,
resolveDateTimeRangeBound,
} from "./date";
import type { RecurrenceAnchor, TaskInfo } from "./types";

Expand Down Expand Up @@ -452,7 +453,8 @@ function getLookAheadDays(recurrence: string): number {

function formatDtstartValue(dateStr: string): string {
if (hasTimeComponent(dateStr)) {
const dateTime = parseDateToLocal(dateStr);
// Task dates are often minute precision ("2026-06-04T10:30"), which the strict parser rejects.
const dateTime = resolveDateTimeRangeBound(dateStr, "from");
const year = dateTime.getFullYear();
const month = String(dateTime.getMonth() + 1).padStart(2, "0");
const day = String(dateTime.getDate()).padStart(2, "0");
Expand Down
45 changes: 45 additions & 0 deletions test/recurrence.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,48 @@ test("advances date-only due offset for recurring tasks with timed scheduled dat
due: "2026-06-06",
});
});

test("adds DTSTART for a minute-precision scheduled time (tasknotes#2328)", async () => {
const { addDTSTARTToRecurrenceRule, updateDTSTARTInRecurrenceRule } = await import(
"../dist/esm/recurrence.js"
);
const withSeconds = addDTSTARTToRecurrenceRule({
recurrence: "FREQ=DAILY",
scheduled: "2026-06-04T10:30:00",
});
assert.equal(
addDTSTARTToRecurrenceRule({ recurrence: "FREQ=DAILY", scheduled: "2026-06-04T10:30" }),
withSeconds
);
assert.equal(updateDTSTARTInRecurrenceRule("FREQ=DAILY", "2026-06-04T10:30"), withSeconds);
assert.match(withSeconds, /^DTSTART:20260604T103000Z;FREQ=DAILY$/);
});

test("completing a materialized occurrence of a timed parent advances it (tasknotes#2328)", async () => {
const { buildMaterializedOccurrenceCompletePlan } = await import("../dist/esm/operations.js");
const plan = buildMaterializedOccurrenceCompletePlan({
occurrenceTask: {
path: "Tasks/Standup 2026-06-04.md",
title: "Standup",
status: "open",
recurrence_parent: "[[Tasks/Standup]]",
occurrence_date: "2026-06-04",
scheduled: "2026-06-04T10:30",
},
parentTask: {
path: "Tasks/Standup.md",
title: "Standup",
status: "open",
recurrence: "FREQ=DAILY",
scheduled: "2026-06-04T10:30",
complete_instances: [],
skipped_instances: [],
},
completedStatus: "done",
currentTimestamp: "2026-06-04T11:00:00.000Z",
completionDate: "2026-06-04",
maintainDueDateOffsetInRecurring: true,
});
assert.deepEqual(plan.parentUpdates.complete_instances, ["2026-06-04"]);
assert.equal(plan.parentUpdates.scheduled, "2026-06-05T10:30");
});
Loading