parse_duration drops the days (d) unit#61
Open
cyrillical00 wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testspython -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.