Skip to content

fix: add days (d) unit support to parse_duration#21

Open
florerialife-ship-it wants to merge 1 commit into
tine1117:mainfrom
florerialife-ship-it:fix/parse-duration-days-unit
Open

fix: add days (d) unit support to parse_duration#21
florerialife-ship-it wants to merge 1 commit into
tine1117:mainfrom
florerialife-ship-it:fix/parse-duration-days-unit

Conversation

@florerialife-ship-it
Copy link
Copy Markdown

The parse_duration function silently ignored the d (days) unit even though:

  1. The token regex _TOKEN already accepted d as a valid suffix
  2. The README explicitly listed d as a supported unit

This caused inputs like "1d" to return 0 instead of 86400, and "2d4h" to return 14400 instead of 187200.

Changes

  • Added "d": 86400 to the _UNITS mapping in duration_utils.py
  • Added test_days — verifies parse_duration("1d") == 86400
  • Added test_days_combined — verifies parse_duration("2d4h") == 187200
  • All 9 tests pass (2 new + 7 existing)

Testing

python -m unittest discover -s tests -v
# Ran 9 tests in 0.004s — OK

Fixes #1

The _UNITS mapping was missing the 'd' (days) entry, even though
the token regex already accepted 'd' and the README documented it
as a supported unit. This caused parse_duration to silently ignore
day values instead of converting them to seconds.

- Added 'd': 86400 to _UNITS
- Added test_days (1d == 86400)
- Added test_days_combined (2d4h == 187200)
- All existing tests continue to pass

Fixes tine1117#1
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