Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/formatters/formatSyntax.docs-examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ describe("Format Syntax documentation examples", () => {
}
});

it("applies documented DATE +N day offsets instead of concatenating them", async () => {
const formatter = new DocsExampleFormatter();

await expect(formatter.render("Review on {{DATE+7}}")).resolves.toBe(
"Review on 2026-05-14",
);
await expect(formatter.render("{{DATE:YYYY-MM-DD+3}}")).resolves.toBe(
"2026-05-10",
);
});

it("collects requirements from the current and 2.12.0 examples", async () => {
for (const example of CURRENT_AND_2120_EXAMPLES) {
const collector = new RequirementCollector(makeApp(), makePlugin());
Expand Down
17 changes: 17 additions & 0 deletions src/formatters/formatter-datesnap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ describe("{{DATE}} snap through replaceDateInString", () => {
expect(f.renderDate("{{DATE:YYYY-MM-DD+7|startof:week}}")).toBe("2023-06-04");
});

it("renders the documented +N day offsets from issue #1704", () => {
expect(f.renderDate("{{DATE}}")).toBe("2023-06-01");
expect(f.renderDate("{{DATE:YYYY-MM-DD}}")).toBe("2023-06-01");
expect(f.renderDate("{{DATE+3}}")).toBe("2023-06-04");
expect(f.renderDate("{{DATE:YYYY-MM-DD+3}}")).toBe("2023-06-04");
expect(f.renderDate("{{DATE+-3}}")).toBe("2023-05-29");
// DATE_REGEX is case-insensitive; lowercase must not fall through to
// Moment as a format suffix (the 2026-08-26+3 concatenation symptom).
expect(f.renderDate("{{date+3}}")).toBe("2023-06-04");
expect(f.renderDate("{{date:YYYY-MM-DD+3}}")).toBe("2023-06-04");
expect(
f.renderDate(
"# works\n{{DATE:YYYY-MM-DD}}\n\n{{DATE}}\n\n# buggy\n{{DATE:YYYY-MM-DD+3}}\n\n{{DATE+3}}\n",
),
).toBe("# works\n2023-06-01\n\n2023-06-01\n\n# buggy\n2023-06-04\n\n2023-06-04\n");
});

it("keeps a literal pipe byte-identical and a [literal |startof: x] intact", () => {
expect(f.renderDate("{{DATE:YYYY|MM}}")).toBe("2023|06");
expect(
Expand Down