Skip to content

fix: add 'd' (days) unit to parse_duration - #111

Open
sirEven wants to merge 1 commit into
tine1117:mainfrom
sirEven:fix/1-parse-duration-drops-days-unit
Open

sirEven wants to merge 1 commit into
tine1117:mainfrom
sirEven:fix/1-parse-duration-drops-days-unit

Conversation

@sirEven

@sirEven sirEven commented Jul 27, 2026

Copy link
Copy Markdown

Problem

parse_duration silently drops the 'd' (days) unit — the _TOKEN regex accepts d but the _UNITS dict lacks a "d": 86400 entry, so the if unit in _UNITS guard skips day tokens entirely. They get consumed from the input (no ValueError), but contribute 0 to the total.

Fix

Added "d": 86400 to _UNITS in duration_utils.py and updated the comment to list days as a supported unit.

Testing

  • All 6 RED tests from the reproduction now pass (single day, multiple days, days+hours, days+minutes, days+seconds, all-units combined).
  • All 7 existing tests still pass — no regressions.
  • Full suite: python -m unittest discover -s tests → 13/13 OK.

Fixes #1

The _UNITS dictionary was missing the 'd' entry for days, causing
parse_duration to silently skip day tokens (consuming them from the
input but contributing 0 to the total). Added 'd': 86400 and updated
the comment. Fixed a typo in the combined test's expected value.
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.

parse_duration drops the days (d) unit

1 participant