Skip to content

Time range#22

Merged
zhangt58 merged 3 commits intomasterfrom
time-range
Sep 19, 2025
Merged

Time range#22
zhangt58 merged 3 commits intomasterfrom
time-range

Conversation

@zhangt58
Copy link
Owner

Use natural English define the time range vs the to time (defaults to now)

@zhangt58 zhangt58 requested a review from Copilot September 19, 2025 19:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds natural-language time range handling to the CLI by introducing a --time-span option and support for "ago" in relative datetime parsing, with --to defaulting to now.

  • Introduce --time-span for natural language ranges (e.g., "3 hours ago")
  • Add iso_to_datetime to standardize and parse ISO8601 inputs
  • Default --to to the current time and compute --from when omitted

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
setup.py Bump package version to 1.0.3-1
pyproject.toml Bump project version to 1.0.3-1
main/tests/test_datetime.py Add tests for parse_dt supporting "ago"
main/scripts/get.py Implement time range defaults and parsing using iso_to_datetime/parse_dt
main/data/utils.py Add iso_to_datetime and extend parse_dt to handle "ago"
main/data/init.py Export iso_to_datetime

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

t_now_o, t_now = standardize_datetime(datetime_with_timezone(datetime.now()))

#
time_span = args.time_span + "before"
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

Missing space before 'before' yields strings like '6 hoursbefore'. While parse_dt strips markers, this is brittle. Use a spaced concat: time_span = f"{args.time_span} before".

Suggested change
time_span = args.time_span + "before"
time_span = f"{args.time_span} before"

Copilot uses AI. Check for mistakes.
Comment on lines +311 to +312
def iso_to_datetime(s: str) -> tuple[datetime, str]:
""" Parse a ISO8601 string into a datetime object with ZoneInfo.
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The docstring mentions returning a datetime object, but the function returns a (datetime, iso_string) tuple normalized to UTC. Update the docstring to document the tuple return and UTC normalization.

Copilot uses AI. Check for mistakes.
@zhangt58 zhangt58 merged commit d6d0829 into master Sep 19, 2025
7 checks passed
@zhangt58 zhangt58 deleted the time-range branch September 19, 2025 20:05
@zhangt58 zhangt58 mentioned this pull request Sep 19, 2025
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