Skip to content

test(format): lock DATE+N offsets from issue 1704 - #1707

Open
chhoumann wants to merge 1 commit into
masterfrom
cursor/issue-1704-date-offset-bb88
Open

test(format): lock DATE+N offsets from issue 1704#1707
chhoumann wants to merge 1 commit into
masterfrom
cursor/issue-1704-date-offset-bb88

Conversation

@chhoumann

@chhoumann chhoumann commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Summary

Lock the documented {{DATE+N}} / {{DATE:YYYY-MM-DD+N}} day-offset behavior so the concatenation and leftover-token symptoms from #1704 cannot regress silently.

This does not change formatter production code. On current master (QuickAdd 2.23.0), those tokens already resolve to a shifted date.

Refs #1704 (not Fixes) — the reported bug was not reproducible in this checkout, so the issue should stay open until a maintainer confirms with the reporter.

Why

#1704 reports that, with a frozen "today" of 2026-08-26:

  • {{DATE:YYYY-MM-DD}} and {{DATE}} work
  • {{DATE:YYYY-MM-DD+3}} becomes 2026-08-26+3 instead of 2026-08-29
  • {{DATE+3}} is left unparsed
  • |startof: / |endof: snap examples also fail

DATE_REGEX / DATE_REGEX_FORMATTED already split format from +N, and replaceDateInString applies getDate({ format, offset, snap }). The previous docs-examples suite only asserted that no {{...}} token remained, so 2026-08-26+3 would still have passed.

Scope

  • Assert issue [BUG] Templates - Relative date does not work #1704's exact template body (and lowercase {{date+3}}, since the regex is /i/) in formatter-datesnap.test.ts against a frozen clock.
  • Assert the documented examples {{DATE+7}} and {{DATE:YYYY-MM-DD+3}} render the shifted date in formatSyntax.docs-examples.test.ts.
  • No src/ production, docs, or bundle changes.

Tradeoffs

  • Test-only lock instead of a formatter change, because the matching surface already does the documented thing. Inventing a production patch would be a no-op or a behavior change we cannot justify.
  • Not closing [BUG] Templates - Relative date does not work #1704 from this PR. Auto-close on a "cannot reproduce" result would hide a possible environment-specific path we did not hit.

Blast radius

Runtime: none. Tests only. Failure mode if the lock is wrong: CI red on a date-format change, not a user-facing change.

Testing / validation

  • pnpm run test — 4989 passed, 37 skipped
  • pnpm run lint — clean
  • Live Obsidian 1.13.7 + QuickAdd 2.23.0 (this checkout), clock frozen to 2026-08-26 12:00:
    • api.format(): {{DATE+3}}2026-08-29, {{DATE:YYYY-MM-DD+3}}2026-08-29 (not 2026-08-26+3)
    • Template choice executeChoice with the issue's markdown created a note whose "buggy" section was 2026-08-29 / 2026-08-29; |startof:week resolved to 2026-08-23

Likely reporter mix-up, not a formatter defect: Obsidian core Templates {{date:YYYY-MM-DD+3}} passes YYYY-MM-DD+3 to Moment (literal +3) and does not parse {{DATE+3}}. Same two symptoms. QuickAdd only expands these tokens when it formats the string (Template / Capture / Macro / api.format()).

Checklist

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Tests
    • Added coverage for documented DATE day-offset formatting.
    • Verified positive and negative offsets, formatted and unformatted dates, lowercase tokens, and multiple dates in multiline text.
    • Confirmed offsets render as adjusted dates rather than appearing in the formatted output.

Issue #1704 reported {{DATE:YYYY-MM-DD+3}} concatenating +3 and
{{DATE+3}} left unparsed. The formatter already applies the offset
(including case-insensitive date tokens). Assert the documented
examples so concatenation cannot regress silently.

Co-authored-by: Christian Bager Bach Houmann <[email protected]>
@chhoumann
chhoumann marked this pull request as ready for review August 27, 2026 22:02
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 22b5aae5-35f8-4dc7-8fe7-d017a6535d3a

📥 Commits

Reviewing files that changed from the base of the PR and between 441863a and 91e70d1.

📒 Files selected for processing (2)
  • src/formatters/formatSyntax.docs-examples.test.ts
  • src/formatters/formatter-datesnap.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds tests for DATE day offsets. The tests cover documented syntax, formatted and unformatted tokens, positive and negative offsets, lowercase tokens, and multiple tokens in multiline text.

Changes

DATE offset validation

Layer / File(s) Summary
DATE offset syntax validation
src/formatters/formatSyntax.docs-examples.test.ts, src/formatters/formatter-datesnap.test.ts
Tests verify adjusted dates for documented offset syntax and integration cases, including formatting variants, token casing, negative offsets, and multiline replacement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 91e70

This change only strengthens automated coverage for existing date-offset formatting behavior and does not alter production code; no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checked the dates at night
Seven hops moved one day marker right
Three more hops made the format shine
Minus hops worked in perfect line
Each token found its proper time

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the added formatter tests, the DATE+N offset behavior, and the related issue. It is concise and specific.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/issue-1704-date-offset-bb88

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 91e70d1
Status: ✅  Deploy successful!
Preview URL: https://a8814cbd.quickadd.pages.dev
Branch Preview URL: https://cursor-issue-1704-date-offse.quickadd.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants