-
Notifications
You must be signed in to change notification settings - Fork 44
Support fractional durations (with precision safeguards, without any new dependency) #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
This was referenced Aug 14, 2025
Member
|
I took care of the reformatting changes to make sure they don't end up in this PR. Please rebase on |
a4dca0d to
7edd006
Compare
Contributor
Author
|
rebased :) |
djc
reviewed
Aug 15, 2025
7edd006 to
e960084
Compare
e960084 to
32701e2
Compare
32701e2 to
2264f65
Compare
Contributor
Author
|
I've fixed clippy's remark. |
djc
approved these changes
Sep 11, 2025
Member
|
Thanks! |
Merged
9999years
added a commit
to MercuryTechnologies/ghciwatch
that referenced
this pull request
Sep 11, 2025
This allows usage like `ghciwatch --debounce 0.1s`. Previously, decimals were not supported, so you had to do (e.g.) `--debounce 100ms`, which was not very intuitive. See: chronotope/humantime#56
9999years
added a commit
to MercuryTechnologies/ghciwatch
that referenced
this pull request
Sep 11, 2025
This allows usage like `ghciwatch --debounce 0.1s`. Previously, decimals were not supported, so you had to do (e.g.) `--debounce 100ms`, which was not very intuitive. See: chronotope/humantime#56
kodiakhq bot
pushed a commit
to pdylanross/fatigue
that referenced
this pull request
Sep 12, 2025
Bumps humantime from 2.2.0 to 2.3.0. Release notes Sourced from humantime's releases. 2.3.0 What's Changed Add 'wk', 'wks' for weeks and 'yr', 'yrs' for years by @ryo1kato in chronotope/humantime#50 Allow parsing zero durations with no units by @RobertGauld in chronotope/humantime#43 Use µs not us by @RobertGauld in chronotope/humantime#45 feat: parse_duration("0") by @aatifsyed in chronotope/humantime#55 Support fractional durations (with precision safeguards, without any new dependency) by @TheElectronWill in chronotope/humantime#56 feat: Accept "+00:00" as an alternative way to specify the UTC timezone by @TheElectronWill in chronotope/humantime#59 Fractional tweaks by @djc in chronotope/humantime#60 Commits 7994b71 ci: disable for non-main pushes 1b59068 Bump version to 2.3.0 cacdb93 ci: add audit job 5cc8dc5 ci: add job to check semver compatibility 0d5fe2d Bump version to 2.2.1 fc0e7ea duration: move current value out of Parser 1febd52 duration: track current value as Duration 0adba12 duration: track current nanoseconds as u32 786218f Extract unit parsing 9ff48bf Re-order duration parser methods in top-down order Additional commits viewable in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot merge will merge this PR after your CI passes on it @dependabot squash and merge will squash and merge this PR after your CI passes on it @dependabot cancel merge will cancel a previously requested merge and block automerging @dependabot reopen will reopen this PR if it is closed @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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.
This PR implements the support of fractional durations such as
1.5hand3.2s 0.456us.It does not add any dependency: the parser stays minimal.
Resolves #34.
About Precision
To avoid precision loss, the new function
parse_fractional_partdoes not rely on floats, but parses0.123as a decimal fraction123/1000. This fraction is then added to the duration's value, depending on the unit. Any loss of precision or overflow during the computations is reported as an error, avoiding float problems.u64::MAXis about 1.8×10¹⁹, so it supports plenty of decimal places and a large range of units.The minimum granularity is 1 nanosecond. For example, the following inputs are rejected:
0.5ns,31.0000001ms.