Skip to content

Accept hr and hrs as hour abbreviations - #85

Open
codeofwxz wants to merge 1 commit into
xolox:masterfrom
codeofwxz:accept-hour-abbreviations
Open

codeofwxz wants to merge 1 commit into
xolox:masterfrom
codeofwxz:accept-hour-abbreviations

Conversation

@codeofwxz

Copy link
Copy Markdown

Add hr and hrs to the existing hour aliases, matching the short singular/plural aliases already accepted for seconds and minutes. parse_timespan('1hr') now returns 3600.0, and parse_timespan('2.5 HRS') returns 9000.0. Matching and output formatting otherwise remain unchanged.

Closes #71.

Validation on Windows/Python 3.12: the new regression fails with InvalidTimespan before the change and passes afterward. It covers zero, integer and fractional values, attached/separated units, existing hour aliases, uppercase variants and an invalid near-match. The existing test_parse_timespan and test_format_timespan also pass. Flake8 on both changed files and git diff --check pass. The full terminal/platform suite was not run for this alias-only change.

Copilot AI lite review requested due to automatic review settings September 16, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Update the public parse_timespan() docstring to include hr and hrs.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds hr and hrs as accepted hour aliases for parse_timespan().

Changes:

  • Extends the hour alias list.
  • Adds regression tests for casing, spacing, fractions, and invalid near-matches.
  • The public docstring still needs to document the new aliases.
File summaries
File Summary
humanfriendly/tests.py Adds regression coverage for the new hour abbreviations.
humanfriendly/__init__.py Adds hr and hrs aliases; the parse_timespan() docstring omits them.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread humanfriendly/__init__.py
dict(divider=1, singular='second', plural='seconds', abbreviations=['s', 'sec', 'secs']),
dict(divider=60, singular='minute', plural='minutes', abbreviations=['m', 'min', 'mins']),
dict(divider=60 * 60, singular='hour', plural='hours', abbreviations=['h']),
dict(divider=60 * 60, singular='hour', plural='hours', abbreviations=['h', 'hr', 'hrs']),
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.

Abbreviations 'hr' and 'hrs' for hour unit missing in time_units

2 participants