Skip to content
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

feat(parseutil): Add ParseDurationSecondWithUnits #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cipherboy
Copy link
Contributor

@cipherboy cipherboy commented Nov 1, 2022

This allows ParseDurationSecond to specify custom additional units (such as days, months, and years) which must stand independently of other units (e.g., "5d6mo7y" is not allowed, but "5d", "6mo", and "7y" are), mapping them to time.Duration values.

Signed-off-by: Alexander Scheel <[email protected]>


I was going to use this when parsing configuration values for the health check, to allow durations longer than days to be parsed. For things like CA validity period and other long-lived values, this'd be generally useful I think.

Note that this isn't a full-featured reimplementation of https://cs.opensource.google/go/go/+/refs/tags/go1.19.2:src/time/format.go;l=1522 with custom units though; the existing behavior is preserved (requiring exclusivity of units).

@cipherboy cipherboy added the enhancement New feature or request label Nov 1, 2022
@cipherboy cipherboy requested a review from sgmiller November 1, 2022 13:44
This allows ParseDurationSecond to specify custom additional units (such
as days, months, and years) which must stand independently of other
units (e.g., "5d6mo7y" is not allowed, but "5d", "6mo", and "7y" are),
mapping them to time.Duration values.

Signed-off-by: Alexander Scheel <[email protected]>
@cipherboy cipherboy force-pushed the cipherboy-add-durations-with-units branch from 46324d5 to 96d5398 Compare December 20, 2022 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant