package
module
Version:
v0.2.1
Opens a new window with list of versions in this module.
Published: Jan 4, 2024
License: MIT
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
README
¶
humanduration
convert a human readable duration to time.Duration
this module is a port of parse-duration, from JavaScript to Go.
usage
go get git.sr.ht/~nbsp/humanduration
contributing
send patches to the mailing list. prefix patches with "[PATCH humanduration]
".
see the guide to git send-email
if this is your first time using sourcehut.
license
humanduration is licensed under the MIT license. refer to the license for details.
Documentation
¶
Package humanduration implements a parser from human-readable durations to
time.Duration.
ErrInvalidUnit signifies that the specified unit could not be parsed into
a duration.
Parse takes a human-readable duration and converts it to a Go time.Duration.
package main
import (
"fmt"
"git.sr.ht/~nbsp/humanduration"
)
func main() {
duration, _ := humanduration.Parse("1 day, 3hrs 2sec")
fmt.Println(duration)
}
Output:
27h0m2s
Source Files
¶
Click to show internal directories.
Click to hide internal directories.