Skip to content

parse_duration drops the days (d) unit#61

Open
cyrillical00 wants to merge 1 commit into
tine1117:mainfrom
cyrillical00:bounty-bot/bounty-github-tine1117-oss-hunter-livef-fa6582
Open

parse_duration drops the days (d) unit#61
cyrillical00 wants to merge 1 commit into
tine1117:mainfrom
cyrillical00:bounty-bot/bounty-github-tine1117-oss-hunter-livef-fa6582

Conversation

@cyrillical00

Copy link
Copy Markdown

Closes the bounty.

Summary

Summary: Add the missing 'd' (days) unit to parse_duration and cover it with tests.

Reasoning: The repository had no duration_utils.py yet (only a pyproject.toml declaring it as a py-module), so the file is created from scratch with a regex-based parser that maps all documented units including 'd' to their second values. The fix directly addresses the bug: 'd' maps to 86400 seconds, so parse_duration('1d')==86400 and parse_duration('2d4h')==187200. Tests are added in tests/test_parse_duration.py covering the new 'd' unit specifically as well as all other units and error cases, matching the unittest-based test runner described in the README.

Test commands

  • python -m unittest discover -s tests
  • python -c "from duration_utils import parse_duration; assert parse_duration('1d') == 86400; assert parse_duration('2d4h') == 187200; print('OK')"

Submitted via bounty-bot. Confidence: high.

Summary: Add the missing 'd' (days) unit to parse_duration and cover it with tests.

Reasoning: The repository had no duration_utils.py yet (only a pyproject.toml declaring it as a py-module), so the file is created from scratch with a regex-based parser that maps all documented units including 'd' to their second values. The fix directly addresses the bug: 'd' maps to 86400 seconds, so parse_duration('1d')==86400 and parse_duration('2d4h')==187200. Tests are added in tests/test_parse_duration.py covering the new 'd' unit specifically as well as all other units and error cases, matching the unittest-based test runner described in the README.

Drafted by bounty-bot for 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.

1 participant