diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-05-22 12:54:00 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-05-22 12:54:00 -0400 |
commit | 4c683aff7627040ff811f065848a820b2cb19d59 (patch) | |
tree | 668061e8acfd8827fd02bab18a998b7986944296 /vendor/github.com/hako/durafmt/README.md | |
parent | eb78d273f39202046fa71555a5a19b0ec8a95cb3 (diff) | |
parent | 1af1bce6199597bb2d41ddcdc00ef0f28a73c83e (diff) | |
download | chat-4c683aff7627040ff811f065848a820b2cb19d59.tar.gz chat-4c683aff7627040ff811f065848a820b2cb19d59.tar.bz2 chat-4c683aff7627040ff811f065848a820b2cb19d59.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'vendor/github.com/hako/durafmt/README.md')
-rw-r--r-- | vendor/github.com/hako/durafmt/README.md | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/vendor/github.com/hako/durafmt/README.md b/vendor/github.com/hako/durafmt/README.md index 128819282..6b26faaf3 100644 --- a/vendor/github.com/hako/durafmt/README.md +++ b/vendor/github.com/hako/durafmt/README.md @@ -33,7 +33,7 @@ The above seems very easy to read, unless your duration looks like this: package main import ( - "fmt" + "fmt" "github.com/hako/durafmt" ) @@ -47,6 +47,28 @@ func main() { } ``` +### durafmt.ParseStringShort() + +Version of `durafmt.ParseString()` that only returns the first part of the duration string. + +```go +package main + +import ( + "fmt" + "github.com/hako/durafmt" +) + +func main() { + duration, err := durafmt.ParseStringShort("354h22m3.24s") + if err != nil { + fmt.Println(err) + } + fmt.Println(duration) // 2 weeks + // duration.String() // String short representation. "2 weeks" +} +``` + ### durafmt.Parse() ```go @@ -65,6 +87,26 @@ func main() { } ``` +### durafmt.ParseShort() + +Version of `durafmt.Parse()` that only returns the first part of the duration string. + +```go +package main + +import ( + "fmt" + "time" + "github.com/hako/durafmt" +) + +func main() { + timeduration := (354 * time.Hour) + (22 * time.Minute) + (3 * time.Second) + duration := durafmt.ParseShort(timeduration).String() + fmt.Println(duration) // 2 weeks +} +``` + # Contributing Contributions are welcome! Fork this repo and add your changes and submit a PR. |