Home

Awesome

duration Test GoDoc

duration.Parse() parses a formatted string and returns the time.Duration value it represents.

Usage

package duration_test

import (
	"fmt"

	"github.com/k1LoW/duration"
)

func ExampleParse() {
	d, _ := duration.Parse("3 days 4 hours")
	fmt.Printf("%s", d)
	// Output: 76h0m0s
}

Supported unit of time

Unit of timevalue
nstime.Nanosecond
nsectime.Nanosecond
nanosecondtime.Nanosecond
nanosecondstime.Nanosecond
ustime.Microsecond
usectime.Microsecond
microsecondtime.Microsecond
microsecondstime.Microsecond
mstime.Millisecond
msectime.Millisecond
millisecondtime.Millisecond
millisecondstime.Millisecond
stime.Second
sectime.Second
secondtime.Second
secondstime.Second
mtime.Minute
mintime.Minute
minutetime.Minute
minutestime.Minute
htime.Hour
hourtime.Hour
hourstime.Hour
dtime.Hour * 24
daytime.Hour * 24
daystime.Hour * 24
wtime.Hour * 24 * 7
weektime.Hour * 24 * 7
weekstime.Hour * 24 * 7