Skip to content

feat: replace python-dateutil with dateparser for natural language support#33

Open
tobixen wants to merge 2 commits intomasterfrom
feat/use-dateparser
Open

feat: replace python-dateutil with dateparser for natural language support#33
tobixen wants to merge 2 commits intomasterfrom
feat/use-dateparser

Conversation

@tobixen
Copy link
Member

@tobixen tobixen commented Mar 21, 2026

⚠️ This comment is AI-generated (Claude Sonnet 4.6 via Claude Code) on behalf of tobixen

Summary

  • Replace python-dateutil dependency with dateparser
  • dateparser understands natural language input that dateutil.parser does not: "yesterday", "3 hours ago", "Friday", "last week", etc.
  • The existing +offset and "now" special cases handled before the parser call are preserved unchanged
  • dateutil.parser.ParserError catch in _parse_timespec replaced with ValueError (dateparser returns None on failure rather than raising; _parse_dt now raises ValueError in that case)
  • All 29 existing tests still pass; 5 new natural language tests added

Motivation

dateutil.parser.parse("yesterday") raises a ParserError. This means users cannot write things like plann select --from yesterday — they have to spell out the ISO date. dateparser handles this family of inputs out of the box.

Test plan

  • All existing tests/test_timespec.py tests pass (29 passed, 1 skipped)
  • New TestNaturalLanguage tests added covering: yesterday, today, 3 hours ago, day name, invalid input

⚠️ This comment is AI-generated (Claude Sonnet 4.6 via Claude Code) on behalf of tobixen

tobixen and others added 2 commits March 14, 2026 13:37
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…pport

dateparser understands "yesterday", "3 hours ago", "Friday", etc. that
dateutil.parser does not.  The +offset and "now" special cases handled
before the parser call are preserved unchanged.

In _parse_timespec the dateutil.parser.ParserError catch is replaced with
ValueError (dateparser returns None on failure rather than raising, and
_parse_dt now raises ValueError in that case).

Adds TestNaturalLanguage tests covering yesterday, today, relative hours,
day names, and invalid input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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