Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApproximateDuration ¶ added in v0.0.5
func ApproximateDuration(d ISO8601Duration) time.Duration
ApproximateDuration converts a senseyeio/duration.Duration to a time.Duration. Calendar units use fixed conversions: days and weeks are 24h and 7×24h; months and years are 30 and 365 days. No origin or timezone is used, so the result is a single Go time.Duration value suitable for timeouts, intervals, or other cases where fixed conversion is enough.
func FormatISO8601Duration ¶ added in v0.0.4
FormatISO8601Duration converts a time.Duration to an ISO 8601 duration string using only the PT (time) prefix with H, M, and S designators. Durations >= 24h result in a large hour value (e.g. PT1000H30M) rather than using date designators. Sub-second precision is truncated. Negative durations are prefixed with "-".
func ParseISO8601Duration ¶
ParseISO8601Duration parses an ISO 8601 duration string (e.g. PT5M, P1D) into a time.Duration. Calendar units use fixed conversions: days and weeks are 24h and 7×24h; months and years are 30 and 365 days. No origin or timezone is used, so the result is a single Go time.Duration value suitable for timeouts, intervals, or other cases where fixed conversion is enough.
To shift a specific time by an ISO 8601 duration (e.g. "one day from now" in local time, respecting DST), use github.com/senseyeio/duration: parse with duration.ParseISO8601 and call Shift(origin). Note that Shift uses time.AddDate for months and years, so month boundaries have the usual rollover behavior (e.g. Aug 31 + P1M → Oct 1).