Skip to content

fix: format VDATE values passed via API/URL params (#1074)#1101

Merged
chhoumann merged 1 commit intomasterfrom
1074-bug-the-date-passed-as-a-parameter-is-not-rendered-in-the-template-as-a-date
Feb 6, 2026
Merged

fix: format VDATE values passed via API/URL params (#1074)#1101
chhoumann merged 1 commit intomasterfrom
1074-bug-the-date-passed-as-a-parameter-is-not-rendered-in-the-template-as-a-date

Conversation

@chhoumann
Copy link
Owner

@chhoumann chhoumann commented Feb 5, 2026

What

Fixes VDATE formatting when template variables are provided via the QuickAdd JS API or obsidian://quickadd URL params. Previously, passing a date like 2026-12-31 would be rendered as the raw string (e.g. 2026-12-31) even when the template used a formatted VDATE token like {{VDATE:date,DD MMMM YYYY}}.

Fixes #1074

Why

VDATE formatting only kicked in when a variable was stored in QuickAdd’s internal date encoding (@date:<ISO>), which is normally created when the user is prompted for a date. Values passed in via API/URL are plain strings, so they never got parsed/coerced into the date form and the formatter fell back to echoing the original value.

How

When a VDATE token is processed and the variable already exists:

  • If it’s a plain string (and not @date:), normalize + parse it using the date parser and, if successful, coerce it into @date:<ISO> so the existing formatting path is used.
  • If it’s a Date object, coerce it into @date:<ISO> as well.
  • If parsing fails, keep the original value (backwards-compatible behavior).

Validation

  • Added a regression unit test covering the API/URL scenario (pre-seeded string variable used by {{VDATE:...}} is parsed + formatted).
  • bun run test
  • bun run lint
  • bun run build

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickadd Ready Ready Preview Feb 5, 2026 11:30pm

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The changes enhance date variable formatting in the formatter by supporting multiple input types (strings, Date objects) through coercion pathways. Type handling is relaxed with strengthened guards, allowing safe fallback to string conversion while maintaining backward compatibility.

Changes

Cohort / File(s) Summary
Date Handling Enhancement
src/formatters/formatter.ts
Relaxed type constraints for stored date variable lookups and introduced coercion pathways for string-based VDATE values. Added support for Date objects via JS API, enhanced non-@Date value formatting logic with type guards, and strengthened conditional checks to prevent runtime errors with non-string inputs.
Test Coverage
src/formatters/vdate-default.test.ts
Added test case validating pre-seeded string variables are parsed as dates through the replaceDateVariableInString pathway, ensuring the date parser coercion logic functions correctly for string inputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Through types both old and types both new,
Our dates now dance where strings once grew,
With guards that catch and coerce with grace,
Each format finds its rightful place!
No errors thrown—just safe parsing fun,
Backward compatible for everyone! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main change: fixing VDATE formatting for values passed via API/URL parameters, which is the core objective reflected in both the file changes and the issue context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 1074-bug-the-date-passed-as-a-parameter-is-not-rendered-in-the-template-as-a-date

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 and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3da8cde
Status: ✅  Deploy successful!
Preview URL: https://2dcb3fe0.quickadd.pages.dev
Branch Preview URL: https://1074-bug-the-date-passed-as.quickadd.pages.dev

View logs

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@chhoumann chhoumann changed the title Unable to proceed in read-only sandbox fix: format VDATE values passed via API/URL params (#1074) Feb 6, 2026
@chhoumann chhoumann merged commit 0dd209d into master Feb 6, 2026
5 checks passed
@chhoumann chhoumann deleted the 1074-bug-the-date-passed-as-a-parameter-is-not-rendered-in-the-template-as-a-date branch February 6, 2026 11:28
@github-actions
Copy link

github-actions bot commented Feb 8, 2026

🎉 This PR is included in version 2.11.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The date passed as a parameter is not rendered in the template as a date

1 participant