Skip to content

fix: add days (d) unit to parse_duration#22

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

fix: add days (d) unit to parse_duration#22
sam-bamboo1979 wants to merge 1 commit into
tine1117:mainfrom
sam-bamboo1979:fix/parse-duration-days

Conversation

@sam-bamboo1979
Copy link
Copy Markdown

Fixes #1

Problem

parse_duration silently drops the days (d) unit. The token regex already accepts d in [wdhms], but _UNITS was missing the d key, causing day values to be ignored.

parse_duration("1d")     # -> 0        (expected 86400)
parse_duration("2d4h")   # -> 14400    (expected 187200)

Fix

  • Added "d": 86400 to _UNITS dict
  • Added test_days and test_days_combined tests
  • Updated docstring to show day example

Verification

All 9 tests pass (7 existing + 2 new):

test_days ... ok
test_days_combined ... ok

The token regex already accepts 'd' in [wdhms], but _UNITS was missing
the 'd' key, causing parse_duration to silently drop day values.

- Add 'd': 86400 to _UNITS dict
- Add test_days and test_days_combined tests
- Update docstring to show day example

Fixes tine1117#1
@sam-bamboo1979
Copy link
Copy Markdown
Author

Hi! Just wanted to follow up on this PR. It's been a few days since submission and I wanted to check if there's anything I can do to help move this along. Happy to make any adjustments if needed. Thanks for your time!

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