Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 21, 2025

The CLI was incorrectly interpreting date-only strings like --until 2025-08-06 by using the current time instead of defaulting to 00:00:00 (midnight). This caused unexpected behavior where users expected the date to represent the start of the day.

Problem

When using the CLI with date-only parameters, the FuzzyDateTime class was using parsedatetime.Calendar().parseDT() which defaults to the current time for the time component:

# User expects this to mean "2025-08-06 00:00:00"
dispatch-cli create 1 test BATTERY "2025-08-06" 1h --until "2025-08-06"

# But it was interpreted as "2025-08-06 14:30:15" (current time)

Solution

Added intelligent detection of date-only strings using regex patterns to distinguish between:

  • Date-only formats: 2025-08-06, 2025/08/06, 08/06/2025, 08-06-2025
  • Relative expressions: in 1 hour, tomorrow, in 2 days

For date-only strings, the parser now uses a sourceTime parameter set to midnight, ensuring consistent behavior. Relative time expressions continue to use the current time as the reference point.

Changes

  • Modified FuzzyDateTime.convert() in _cli_types.py to detect date-only patterns
  • Added regex patterns for common date formats (ISO, slash, US, dash formats)
  • Preserved all existing functionality for relative time expressions and explicit datetime strings

Testing

  • All existing CLI tests continue to pass
  • Date-only strings now correctly default to midnight (00:00:00)
  • Relative time expressions like "in 1 hour" still work as expected
  • Multiple date formats are supported consistently

Fixes #198.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 21, 2025

@Marenz 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] CLI: Interpretation of "--end-time-to 2025-08-06" will use the current time instead of 00:00 Fix CLI datetime parsing to default date-only strings to midnight instead of current time Aug 21, 2025
@Copilot Copilot AI requested a review from Marenz August 21, 2025 10:18
Copilot finished work on behalf of Marenz August 21, 2025 10:18
@github-actions github-actions bot added part:cli Affects the command-line interface part:dispatcher labels Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:cli Affects the command-line interface part:dispatcher
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: Interpretation of "--end-time-to 2025-08-06" will use the current time instead of 00:00
2 participants