Skip to content

fix: resolve natural language dates when converting filters to Bases - #2403

Closed
thaidmfinnick wants to merge 1 commit into
callumalpass:mainfrom
thaidmfinnick:fix/bases-natural-language-dates
Closed

thaidmfinnick wants to merge 1 commit into
callumalpass:mainfrom
thaidmfinnick:fix/bases-natural-language-dates

Conversation

@thaidmfinnick

@thaidmfinnick thaidmfinnick commented Oct 15, 2026 •

Copy link
Copy Markdown

Problem

BasesFilterConverter copies natural language date values as plain strings:

Filter Generated Bases expression Result
due is today note.due == "today" never matches
due is on or before today note.due <= "today" string comparison; digits sort before letters, so every date matches, including future ones

The in-memory filter (FilterUtils) resolves these values with resolveNaturalLanguageDate, but the Bases converter never does, so converted saved views behave differently from the original v3 views.

Fix

  • Add getNaturalLanguageDateOffsetDays() to dateUtils. It returns the day offset for the same patterns resolveNaturalLanguageDate supports (today, tomorrow, yesterday, next/last week, in N days/weeks, N days/weeks ago).

  • In convertOperator, when a date property (due, scheduled, completedDate, dateCreated, dateModified, or a date user field) is compared to a natural language value, emit an expression relative to today(). The comparison uses the date part, like FilterUtils and the default base templates do:

    (!note.due.isEmpty() && date(note.due).format("YYYY-MM-DD") == today().format("YYYY-MM-DD"))
    (!note.due.isEmpty() && date(note.due).format("YYYY-MM-DD") <= (today() + "3 days").format("YYYY-MM-DD"))
    

    The date stays relative, so the generated .base file is still correct on later days.

  • Literal dates and non-date properties are unchanged.

Tests

  • New tests/unit/services/BasesFilterConverter.naturalLanguageDates.test.ts: 13 of its cases fail before this change.
  • npm run test:unit passes, as do eslint and prettier on the changed files and tsc --noEmit.

Video error and demo

Error
https://github.com/user-attachments/assets/6e1a1722-fa61-41e9-8d1e-4cc363777ee0

Saved-view conversion copied natural language date values verbatim, so
`due is today` became `note.due == "today"` (never matches) and
`due is on or before today` became `note.due <= "today"` (a string
comparison that matches every date, including future ones).

Date comparisons against natural language values now emit Bases
expressions relative to today(), compared by date part like FilterUtils.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thaidmfinnick

Copy link
Copy Markdown
Author

Closing: opened by mistake while investigating a v3 issue that's already fixed in v4.

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.

1 participant