We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'd like a way to limit duration strings to the first N adjacent time units.
Existing behaviour:
package main import ( "fmt" "time" "github.com/hako/durafmt" ) func main() { duration := durafmt.Parse(2*time.Hour + 58*time.Second).LimitFirstN(2).String() fmt.Println(duration) }
This returns 2 hours 58 seconds.
2 hours 58 seconds
I don't love this behaviour because the "58 seconds" part is not important and should be truncated. But if I had 58 minutes, that would be important.
Desired behaviour:
duration := durafmt.Parse(2*time.Hour + 58*time.Second).LimitFirstAdjacentN(2).String()
Would return 2 hours.
2 hours
duration := durafmt.Parse(2*time.Hour + 15*time.Minute).LimitFirstAdjacentN(2).String()
Would return 2 hours 15 minutes.
2 hours 15 minutes
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'd like a way to limit duration strings to the first N adjacent time units.
Existing behaviour:
This returns
2 hours 58 seconds
.I don't love this behaviour because the "58 seconds" part is not important and should be truncated. But if I had 58 minutes, that would be important.
Desired behaviour:
Would return
2 hours
.Would return
2 hours 15 minutes
.The text was updated successfully, but these errors were encountered: