package main import ( "fmt" "time" ) func Example_parseCertDuration() { now := time.Date(2020, time.April, 28, 12, 30, 0, 0, time.UTC) fmt.Println(parseCertDuration("", now)) fmt.Println(parseCertDuration("hi!", now)) fmt.Println(parseCertDuration("-2d3h", now)) fmt.Println(parseCertDuration("2d3h", now)) fmt.Println(parseCertDuration("+1y-1s", now)) // output: // 0001-01-01 00:00:00 +0000 UTC // 0001-01-01 00:00:00 +0000 UTC invalid duration: "hi!" // 2020-04-26 09:30:00 +0000 UTC // 2020-04-30 15:30:00 +0000 UTC // 2021-04-28 12:29:59 +0000 UTC }