@@ -15,7 +15,8 @@ go get github.com/xhit/go-str2duration
1515
1616Go String To Duration supports this strings conversions to duration:
1717- All strings returned in time.Duration String.
18- - A string more readable like 1w2d6h3ns (1 week 2 days 6 hours and 3 nanoseconds)
18+ - A string more readable like 1w2d6h3ns (1 week 2 days 6 hours and 3 nanoseconds).
19+ - ` µs ` and ` us ` are microsecond.
1920
2021** Note** : a day is 24 hour.
2122
@@ -58,6 +59,7 @@ func main() {
5859 {" 1s" , time.Duration (time.Second )},
5960 {" 1ms" , time.Duration (time.Millisecond )},
6061 {" 1µs" , time.Duration (time.Microsecond )},
62+ {" 1us" , time.Duration (time.Microsecond )},
6163 {" 1ns" , time.Duration (time.Nanosecond )},
6264 {" 4.000000001s" , time.Duration (4 *time.Second + time.Nanosecond )},
6365 {" 1h0m4.000000001s" , time.Duration (time.Hour + 4 *time.Second + time.Nanosecond )},
@@ -80,6 +82,8 @@ func main() {
8082 // And can be case insensitive
8183 {" 2D3S96NS" , time.Duration (48 *time.Hour + 3 *time.Second + 96 *time.Nanosecond )},
8284
85+ {" 10s1us693ns" , time.Duration (10 *time.Second + time.Microsecond + 693 *time.Nanosecond )},
86+
8387 } {
8488 durationFromString , err := str2duration.Str2Duration (tt.dur )
8589 if err != nil {
0 commit comments