Skip to content

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

Open
trenysx wants to merge 1 commit into
tine1117:mainfrom
trenysx:fix/add-days-unit
Open

trenysx wants to merge 1 commit into
tine1117:mainfrom
trenysx:fix/add-days-unit

Conversation

@trenysx

@trenysx trenysx commented Aug 18, 2026

Copy link
Copy Markdown

Problem

parse_duration silently drops the days (d) unit. The README lists d as a supported unit, but the parser ignores it and returns a wrong (too-small) result.

Root Cause

The _UNITS dict in duration_utils.py was missing the entry for d (days = 86400 seconds). The regex already accepts d as a valid unit character, so the token is matched but the value is never added to the total.

Solution

Added "d": 86400 to the _UNITS dict.

Tests

Added two regression tests:

  • test_days: Verifies parse_duration("1d") == 86400
  • test_days_combined: Verifies parse_duration("2d4h") == 187200

All 9 tests pass.

Bounty

Closes #1

/bounty $50

- Add 'd': 86400 to _UNITS dict in duration_utils.py
- Add regression tests for days and days+hours combinations
- All 9 tests pass
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