Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpectedInput is returned when an input in the duration string does not match expectations ErrUnexpectedInput = errors.New("unexpected input") )
Functions ¶
func Format ¶
Format formats the given time.Duration into an ISO 8601 duration string (e.g., P1DT6H5M), negative durations are prefixed with a minus sign, for a zero duration "PT0S" is returned. Note that for *Duration's with period values of a month or year that the duration becomes a bit fuzzy since obviously those things vary month to month and year to year.
Types ¶
type Duration ¶
type Duration struct { Years float64 Months float64 Weeks float64 Days float64 Hours float64 Minutes float64 Seconds float64 Negative bool }
Duration holds all the smaller units that make up the duration
func FromTimeDuration ¶
FromTimeDuration converts the given time.Duration into duration.Duration. Note that for *Duration's with period values of a month or year that the duration becomes a bit fuzzy since obviously those things vary month to month and year to year.
func Parse ¶
Parse attempts to parse the given duration string into a *Duration, if parsing fails an error is returned instead.
func (Duration) MarshalJSON ¶
MarshalJSON satisfies the Marshaler interface by return a valid JSON string representation of the duration
func (*Duration) ToTimeDuration ¶
ToTimeDuration converts the *Duration to the standard library's time.Duration. Note that for *Duration's with period values of a month or year that the duration becomes a bit fuzzy since obviously those things vary month to month and year to year.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON satisfies the Unmarshaler interface by return a valid JSON string representation of the duration