Documentation
¶
Index ¶
- func ApproximateBins(start, end time.Time, tg TimeGrain) int
- func OffsetTime(tm time.Time, tg TimeGrain, n int, tz *time.Location) time.Time
- func TimeGrainBase(tg runtimev1.TimeGrain) (runtimev1.TimeGrain, int)
- func TimeGrainToAPI(tg TimeGrain) runtimev1.TimeGrain
- func TruncateTime(tm time.Time, tg TimeGrain, tz *time.Location, firstDay, firstMonth int) time.Time
- func WallClockBucketStart(tm time.Time, hours int, tz *time.Location) time.Time
- type TimeGrain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApproximateBins ¶ added in v0.58.0
func OffsetTime ¶ added in v0.60.7
func TimeGrainBase ¶
TimeGrainBase returns the base unit of an API grain and the number of those units it spans. Standard grains return themselves and 1.
func TimeGrainToAPI ¶ added in v0.74.0
func TruncateTime ¶
func WallClockBucketStart ¶
WallClockBucketStart returns the local date and time in tz at which the bucket of an hour multiple that contains tm starts, as a UTC time that holds that wall-clock time. Dialects that step hour multiples on the local clock start their spines from it. It is earlier than the local time of TruncateTime for a bucket that starts in a DST gap, since TruncateTime moves that start past the gap.
Types ¶
type TimeGrain ¶
type TimeGrain int
TimeGrain is extension of std time package with Week and Quarter added
const ( TimeGrainUnspecified TimeGrain = iota TimeGrainMillisecond TimeGrainSecond TimeGrainMinute TimeGrainHour TimeGrainDay TimeGrainWeek TimeGrainMonth TimeGrainQuarter TimeGrainYear // Multiples of a base grain. // They are only used to bucket time series. // Their numeric values are not the grain order: use Compare to order grains. TimeGrain5Minute TimeGrain10Minute TimeGrain15Minute TimeGrain30Minute TimeGrain2Hour TimeGrain3Hour TimeGrain4Hour TimeGrain6Hour TimeGrain8Hour TimeGrain12Hour )
func TimeGrainFromAPI ¶ added in v0.74.0
func (TimeGrain) ApproxDuration ¶
ApproxDuration returns the nominal length of a grain. Calendar grains use fixed approximations, which is enough to order grains and estimate bin counts.