There is no API in standard library for that, but there is a 3rd party library that can add ISO 8601 duration to a time.Time
: https://godoc.org/github.com/senseyeio/duration#Duration.Shift.
ISO 8601 duration can not be generally converted to a time.Duration
because it depends on the base time.Time
.
https://play.golang.org/p/guybDGoJVrT
package main
import (
"fmt"
"time"
"github.com/senseyeio/duration"
)
func main() {
d, _ := duration.ParseISO8601("P1D")
today := time.Now()
tomorrow := d.Shift(today)
fmt.Println(today.Format("Jan _2")) // Nov 11
fmt.Println(tomorrow.Format("Jan _2")) // Nov 12
}