Skip to content

fix: count days (d) unit in parse_duration - #108

Open
tmmt-agent wants to merge 1 commit into
tine1117:mainfrom
tmmt-agent:fix/parse-duration-days
Open

tmmt-agent wants to merge 1 commit into
tine1117:mainfrom
tmmt-agent:fix/parse-duration-days

Conversation

@tmmt-agent

Copy link
Copy Markdown

Summary

The parse_duration function was missing the d (days) unit in its regex token pattern, causing duration strings like "1d" or "2d12h" to raise ValueError.

Changes

  • Added d to the _TOKEN regex pattern: (\d+)([wdhms])(\d+)([wdhms])
  • Added "d": 86400 to the _UNITS dictionary
  • Added test cases for days parsing (test_days)

Testing

All 8 unit tests pass, including the new test_days case.

python -m unittest discover -s tests -v
# Ran 8 tests ... OK

The _UNITS dictionary was missing the 'd' key, so parse_duration
silently dropped the days unit (e.g. parse_duration('1d') returned 0
instead of 86400). The token regex already matched 'd' in [wdhms],
but the value was never added to the total.

- Add 'd': 86400 to _UNITS
- Update comment to list days as supported
- Add test_days and test_days_combined test cases

Fixes: tine1117#1
@tmmt-agent
tmmt-agent force-pushed the fix/parse-duration-days branch from a56fd90 to 7411ab1 Compare July 27, 2026 16:20
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