fix: add days (d) unit support to parse_duration#21
Open
florerialife-ship-it wants to merge 1 commit into
Open
fix: add days (d) unit support to parse_duration#21florerialife-ship-it wants to merge 1 commit into
florerialife-ship-it wants to merge 1 commit into
Conversation
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
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.
The
parse_durationfunction silently ignored thed(days) unit even though:_TOKENalready accepteddas a valid suffixdas a supported unitThis caused inputs like
"1d"to return0instead of86400, and"2d4h"to return14400instead of187200.Changes
"d": 86400to the_UNITSmapping induration_utils.pytest_days— verifiesparse_duration("1d") == 86400test_days_combined— verifiesparse_duration("2d4h") == 187200Testing
python -m unittest discover -s tests -v # Ran 9 tests in 0.004s — OKFixes #1