Documentation ¶
Overview ¶
Package duration copied as it is from github.com/senseyeio/duration
Index ¶
- type Duration
- type InfDuration
- type StandardDuration
- func (d StandardDuration) Add(t time.Time) time.Time
- func (d StandardDuration) EndTime(t time.Time) time.Time
- func (d StandardDuration) EstimateNative() (time.Duration, bool)
- func (d StandardDuration) Sub(t time.Time) time.Time
- func (d StandardDuration) Truncate(t time.Time, firstDayOfWeek, firstMonthOfYear int) time.Time
- type TruncToDateDuration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration interface { Add(t time.Time) time.Time Sub(t time.Time) time.Time EstimateNative() (time.Duration, bool) }
func ParseISO8601 ¶
ParseISO8601 parses an ISO8601 duration as well as some Rill-specific extensions. (Section 3.7 of the standard supposedly allows extensions that do not interfere with the standard.) Current extensions are, 1. "inf" for representing an unbounded duration of time 2. X-To-Date and Previous-X duration supports with a prefix of "rill-" to DAX notations. Pulled from https://www.daxpatterns.com/standard-time-related-calculations/
type InfDuration ¶ added in v0.37.0
type InfDuration struct{}
func (InfDuration) EstimateNative ¶ added in v0.41.0
func (d InfDuration) EstimateNative() (time.Duration, bool)
type StandardDuration ¶ added in v0.37.0
type StandardDuration struct { Year int Month int Week int Day int Hour int Minute int Second int // contains filtered or unexported fields }
StandardDuration represents an ISO8601 duration with Rill-specific extensions. See ParseISO8601 for details.
func (StandardDuration) Add ¶ added in v0.37.0
func (d StandardDuration) Add(t time.Time) time.Time
Add adds the duration to a timestamp
func (StandardDuration) EndTime ¶ added in v0.44.0
func (d StandardDuration) EndTime(t time.Time) time.Time
func (StandardDuration) EstimateNative ¶ added in v0.41.0
func (d StandardDuration) EstimateNative() (time.Duration, bool)
EstimateNative estimates the duration as a native Go duration.
func (StandardDuration) Sub ¶ added in v0.37.0
func (d StandardDuration) Sub(t time.Time) time.Time
Sub subtracts the duration from a timestamp
func (StandardDuration) Truncate ¶ added in v0.41.0
Truncate truncates a timestamp to the duration. It keeps the timezone of the timestamp. It only partially supports durations with multiple components (e.g. P1Y3M): it will truncate by the first component only. TODO: Is there a well-defined way to truncate by multiple components? TODO: Can this be merged with timeutil.TruncateTime? timeutil returns UTC values, whereas this returns in the same tz as the input time.
type TruncToDateDuration ¶ added in v0.37.0
type TruncToDateDuration struct {
// contains filtered or unexported fields
}
func (TruncToDateDuration) Add ¶ added in v0.37.0
func (d TruncToDateDuration) Add(t time.Time) time.Time
func (TruncToDateDuration) EstimateNative ¶ added in v0.41.0
func (d TruncToDateDuration) EstimateNative() (time.Duration, bool)
func (TruncToDateDuration) Sub ¶ added in v0.37.0
func (d TruncToDateDuration) Sub(t time.Time) time.Time