Documentation ¶
Overview ¶
timeutil provides a set of time utilities including comparisons, conversion to "DT8" int32 and "DT14" int64 formats and other capabilities.
Index ¶
- Constants
- Variables
- func AnyStringToQuarterTime(yyyyqSrcStr string) time.Time
- func DT14ForInts(yyyy, mm, dd, hr, mn, dy int) int64
- func DT14ForString(layout, value string) (int64, error)
- func DT6ForDT14(dt14 int64) int32
- func DT6MinMaxSlice(minDt6 int32, maxDt6 int32) []int32
- func DT6Next(dt6 int32) int32
- func DT6Parse(dt6 int32) (int16, int8)
- func DT6Prev(dt6 int32) int32
- func DaysAgoDow(baseDow, wantDow time.Weekday, wantInclusive bool) int
- func DaysAgoDowStrings(baseDowS string, wantDowS string, wantInclusive bool) (int, error)
- func DaysToDow(baseDow, wantDow time.Weekday, wantInclusive bool) int
- func DaysToDowStrings(baseDowS string, wantDowS string, wantInclusive bool) (int, error)
- func Dd6ToTime(dd6 string, reverse bool) (time.Time, error)
- func Distinct(times []time.Time) []time.Time
- func DurationDays(d time.Duration) float64
- func DurationDaysInt64(dur time.Duration) int64
- func DurationStringMinutesSeconds(durationSeconds int64) (string, error)
- func DurationWeeks(d time.Duration) float64
- func DurationYears(d time.Duration) float64
- func Earliest(times []time.Time, skipZeroes bool) (time.Time, error)
- func EqualQuarter(dt1, dt2 time.Time) bool
- func FirstDayOfISOWeek(year int, week int, timezone *time.Location) time.Time
- func FirstNonZeroTime(times ...time.Time) (time.Time, error)
- func FirstNonZeroTimeParsed(format string, times []string) (time.Time, error)
- func FormatDurationInfoMinSec(di DurationInfo) string
- func FormatQuarter(t time.Time) string
- func FormatQuarterYYQ(t time.Time) string
- func FormatQuarterYYYYQ(t time.Time) string
- func FormatTimeMulti(dateFormat string, v any) string
- func FormatTimeToString(format string) func(time.Time) string
- func FromTo(value, fromLayout, toLayout string) (string, error)
- func FromTo2(fromLayout, toLayout, value string) (string, error)
- func FromToFirstValue(fromLayout, toLayout string, values []string) (string, error)
- func FromToFirstValueOrEmpty(fromLayout, toLayout string, values []string) string
- func GetFormat(formatName string) (string, error)
- func GreaterTime(t1, t2 time.Time) time.Time
- func InQuarter(dt time.Time, yyyyq int32) (bool, error)
- func InQuarterRange(dt time.Time, yyyyq1, yyyyq2 int32) (bool, error)
- func InQuarterTime(dt, qtr time.Time) bool
- func InRange(rangeStart, rangeEnd, needle time.Time, incStart, incEnd bool) bool
- func IntToBaseXString(baseX, val int) string
- func IsDTX(d int32) (string, error)
- func IsGreaterThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool
- func IsLessThan(timeLeft time.Time, timeRight time.Time, orEqual bool) bool
- func IsQuarterInt32(q int32) bool
- func Latest(times []time.Time, skipZeroes bool) (time.Time, error)
- func LesserTime(t1, t2 time.Time) time.Time
- func MaxDuration(durs []time.Duration) time.Duration
- func MaxInt32(ints []int32) int32
- func MaxTime(t, max time.Time) time.Time
- func MinInt32(ints []int32) int32
- func MinMax(min, max time.Time) (time.Time, time.Time)
- func MinMaxInt32(ints []int32) (int32, int32)
- func MinTime(t, min time.Time) time.Time
- func MonthEndDay(year int, month time.Month) int
- func MonthNames() []string
- func MonthToQuarter(month uint8) uint8
- func MustFirstNonZeroTime(times ...time.Time) time.Time
- func MustInQuarter(dt time.Time, yyyyq int32) bool
- func MustInQuarterRange(dt time.Time, yyyyq1, yyyyq2 int32) bool
- func MustParse(layout, value string) time.Time
- func MustParseDuration(s string) time.Duration
- func NewDuration(day, hour, min, sec, nsec int) time.Duration
- func NewDurationFloat(day, hour, min, sec float64, nsec int64) time.Duration
- func NewDurationStrings(hour, min, sec string) (time.Duration, error)
- func NowDeltaDuration(d time.Duration) time.Time
- func NowDeltaParseDuration(s string) (time.Time, error)
- func NumQuartersInt32(start, end int32) (int, error)
- func OffsetFormat(offset int, useColon, useZ bool) string
- func ParseDayOfWeek(d string) (time.Weekday, error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseFirst(layouts []string, value string) (time.Time, error)
- func ParseFirstValue(layout string, values []string) (time.Time, error)
- func ParseFirstValueOrZero(layout string, values []string) time.Time
- func ParseHalf(yyyyh int32) (int32, uint8, error)
- func ParseOrZero(layout, value string) time.Time
- func ParseQuarterInt32(yyyyq int32) (int32, uint8, error)
- func ParseQuarterInt32StartEndTimes(yyyyq int32) (time.Time, time.Time, error)
- func ParseQuarterStringStartTime(yyyyqStr string) (time.Time, error)
- func ParseSlice(layout string, strings []string) ([]time.Time, error)
- func ParseTimeSQLTimestampUsingOffset(timeStr string, offset int) (time.Time, error)
- func ParseTimeUsingOffset(format, raw, sep string, offset int, useColon, useZ bool) (time.Time, error)
- func ParseWeekday(s string) (time.Weekday, error)
- func QuarterAdd(t time.Time, count int) time.Time
- func QuarterInt32Add(yyyyq int32, numQuarters int) (int32, error)
- func QuarterInt32End(yyyyq int32) (time.Time, error)
- func QuarterInt32EndTime(yyyyq int32) (time.Time, error)
- func QuarterInt32ForTime(dt time.Time) int32
- func QuarterInt32Now() int32
- func QuarterInt32StartTime(yyyyq int32) (time.Time, error)
- func QuarterInt32Timeline(ints []int32) ([]int32, error)
- func QuarterInt32ToYear(yyyyq int32) int32
- func QuarterProjection(dt time.Time, current float64) float64
- func QuarterSlice(min, max time.Time) []time.Time
- func QuarterStartString(t time.Time) string
- func QuarterStringEndTime(yyyyqStr string) (time.Time, error)
- func QuarterStringStartTime(yyyyqStr string) (time.Time, error)
- func QuarterToMonth(quarter uint8) uint8
- func QuartersInt32RelToAbs(start, end int32) (int32, int32)
- func SliceMinMax(times []time.Time) (time.Time, time.Time)
- func Sort(times []time.Time) []time.Time
- func SubDuration(dur1, dur2 time.Duration) time.Duration
- func SumDurations(durations ...time.Duration) time.Duration
- func TimeDT4AddNYears(t time.Time, numYears int) time.Time
- func TimeDT6AddNMonths(t time.Time, numMonths int) time.Time
- func TimeDeltaDow(base time.Time, wantDow time.Weekday, deltaUnits int, wantInclusive bool, ...) (time.Time, error)
- func TimeDeltaDowInt(base time.Time, wantDow time.Weekday, deltaUnits int, wantInclusive bool, ...) (time.Time, error)
- func TimeDeltaDowString(base time.Time, wantDowS string, deltaUnits int, wantInclusive bool, ...) (time.Time, error)
- func TimeForDT14(dt14 int64) (time.Time, error)
- func TimeForDT6(dt6 int32) (time.Time, error)
- func TimeMinRFC3339() time.Time
- func TimeSeriesMinMax(interval Interval, min, max time.Time) []time.Time
- func TimeSeriesSlice(interval Interval, times []time.Time) []time.Time
- func TimeSliceMinMax(times []time.Time) (time.Time, time.Time, error)
- func TimeToDd6(dt time.Time, reverse bool) (string, error)
- func TimeWithin(this, beg, end time.Time, eqBeg, eqEnd bool) bool
- func TimeZeroRFC3339() time.Time
- func TimeZeroUnix() time.Time
- func Timespec(t syscall.Timespec) time.Time
- func Timeval(t syscall.Timeval) time.Time
- func UnixToDay(epoch int64) time.Time
- func WeekdayNormalized(d time.Weekday) time.Weekday
- type DateTime8
- func (dt8 DateTime8) Format(layout string, loc *time.Location) (string, error)
- func (dt8 DateTime8) Split() (uint32, uint32, uint32)
- func (dt8 DateTime8) SubTime(u time.Time, loc *time.Location) (time.Duration, error)
- func (dt8 DateTime8) Time(loc *time.Location) (time.Time, error)
- func (dt8 *DateTime8) UnmarshalJSON(data []byte) error
- func (dt8 DateTime8) Validate() error
- type DateTime8UnmarshalError
- type DurationInfo
- type DurationInfoString
- type DurationPct
- type Event
- type ISO8601NoTzMilliTime
- type ImpactPct
- type Interval
- type QuarterTimeline
- type RFC3339YMDTime
- type TimeMeta
- type TimeMore
- func (tm TimeMore) DT14() int64
- func (tm TimeMore) DT6() int32
- func (tm TimeMore) DT8() (DateTime8, error)
- func (tm TimeMore) DayEnd() time.Time
- func (tm TimeMore) DayStart() time.Time
- func (tm TimeMore) IntervalStart(interval Interval) (time.Time, error)
- func (tm TimeMore) IsMonthStart() bool
- func (tm TimeMore) IsQuarterStart() bool
- func (tm TimeMore) IsYearStart() bool
- func (tm TimeMore) IsZeroAny() bool
- func (tm TimeMore) MonthEnd() time.Time
- func (tm TimeMore) MonthStart() time.Time
- func (tm TimeMore) Quarter() int32
- func (tm TimeMore) QuarterDuration() time.Duration
- func (tm TimeMore) QuarterEnd() time.Time
- func (tm TimeMore) QuarterStart() time.Time
- func (tm TimeMore) Time() time.Time
- func (tm TimeMore) TimeMeta() TimeMeta
- func (tm TimeMore) WeekEnd() time.Time
- func (tm TimeMore) WeekStart() time.Time
- func (tm TimeMore) WeekStartDay() time.Weekday
- func (tm TimeMore) WeekdayNext(d time.Weekday) time.Time
- func (tm TimeMore) Year() int32
- func (tm TimeMore) YearEnd() time.Time
- func (tm TimeMore) YearStart() time.Time
- type TimeOpts
- type TimeRange
- func (tr *TimeRange) Duration() time.Duration
- func (tr *TimeRange) HasIntersection(tr2 TimeRange) bool
- func (tr *TimeRange) Insert(t time.Time)
- func (tr *TimeRange) InsertMax(t time.Time)
- func (tr *TimeRange) InsertMin(t time.Time)
- func (tr *TimeRange) IntersectionDuration(tr2 TimeRange) time.Duration
- func (tr *TimeRange) Nanoseconds() uint64
- func (tr *TimeRange) Normalize()
- type TimeRanges
- type Times
- func (ts Times) Dedupe() Times
- func (ts Times) Duplicate() Times
- func (ts Times) Equal(compare Times) bool
- func (ts Times) Format(format string) []string
- func (ts Times) Len() int
- func (ts Times) Less(i, j int) bool
- func (ts Times) RangeLower(t time.Time, inclusive bool) (time.Time, error)
- func (ts Times) RangeUpper(t time.Time, inclusive bool) (time.Time, error)
- func (ts Times) Sort()
- func (ts Times) SortReverse()
- func (ts Times) Swap(i, j int)
- type XOXTimes
Constants ¶
const ( DaysPerWeek = float32(7) HoursPerDay = float32(24) SecondsPerYear = (365 * 24 * 60 * 60) + (6 * 60 * 60) SecondsPerWeek = 7 * 24 * 60 * 60 SecondsPerDay = 24 * 60 * 60 NanosPerSecond = int64(1000000000) NanosPerMicrosecond = NanosPerSecond / 1000000 NanosPerMillisecond = NanosPerSecond / 1000 NanosPerMinute = NanosPerSecond * 60 NanosPerHour = NanosPerMinute * 60 NanosPerDay = NanosPerHour * 24 NanosPerWeek = NanosPerDay * 7 NanosPerSecondSub1 = NanosPerSecond - 1 DurationDay = 24 * time.Hour DurationWeek = 7 * DurationDay MonthsEN = `["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]` )
const ( DT14 = "20060102150405" DT8 = "20060102" DT6 = "200601" MonthDay = "1/2" DIN5008FullDate = "02.01.2006" // German DIN 5008 standard DIN5008Date = "02.01.06" RFC3339FullDate = "2006-01-02" RFC3339Milli = "2006-01-02T15:04:05.999Z07:00" RFC3339Dash = "2006-01-02T15-04-05Z07-00" ISO8601 = "2006-01-02T15:04:05Z0700" ISO8601TZHour = "2006-01-02T15:04:05Z07" ISO8601NoTZ = "2006-01-02T15:04:05" ISO8601MilliNoTZ = "2006-01-02T15:04:05.999" ISO8601Milli = "2006-01-02T15:04:05.999Z0700" ISO8601CompactZ = "20060102T150405Z0700" ISO8601CompactNoTZ = "20060102T150405" ISO8601YM = "2006-01" Ruby = "2006-01-02 15:04:05 -0700" // Ruby Time.now.to_s SQLTimestamp = "2006-01-02 15:04:05" // MySQL, BigQuery, etc. SQLTimestampPgTz = "2006-01-02 15:04:05.999999-07" InsightlyAPIQuery = "_1/_2/2006 _3:04:05 PM" DateMDY = "1/_2/2006" DateMDYSlash = "01/02/2006" DateDMYDash = "_2-01-2006" // Jira XML Date format DateDMYHM2 = "02:01:06 15:04" // GMT time in format dd:mm:yy hh:mm DateYMD = RFC3339FullDate DateTextUS = "January _2, 2006" DateTextUSAbbr3 = "Jan _2, 2006" DateTextEU = "_2 January 2006" DateTextEUAbbr3 = "_2 Jan 2006" )
More predefined layouts for use in Time.Format and time.Parse.
const ( RFC3339Min = "0000-01-01T00:00:00Z" RFC3339Max = "9999-12-31T23:59:59Z" RFC3339Zero = "0001-01-01T00:00:00Z" // Golang zero value RFC3339ZeroUnix = "1970-01-01T00:00:00Z" RFC3339YMDZeroUnix = int64(-62135596800) )
const ( LayoutNameDT4 = "dt4" LayoutNameDT6 = "dt6" LayoutNameDT8 = "dt8" LayoutNameDT14 = "dt14" )
const ( NanosecondString = "naonsecond" MicrosecondString = "microsecond" MillisecondString = "millisecond" SecondString = "second" MinuteString = "minute" HourString = "hour" DayString = "day" WeekString = "week" MonthString = "month" QuarterString = "quarter" YearString = "year" DecadeString = "decade" ScoreString = "score" CenturyString = "century" MillenniaString = "millennia" )
Variables ¶
var ( ErrEmptyTimeSlice = errors.New("empty time slice") ErrOutOfBounds = errors.New("out of bounds") ErrOutOfBoundsLower = errors.New("out of bounds lower") ErrOutOfBoundsUpper = errors.New("out of bounds upper") )
var ErrDateTime8Invalid = errors.New("timeutil.datetime8: invalid value")
var ErrDateTime8OutOfBounds = errors.New("datetime8: time.Time is out of bounds")
var FormatMap = map[string]string{ "RFC3339": time.RFC3339, "RFC3339YMD": RFC3339FullDate, "ISO8601YM": ISO8601YM, }
Functions ¶
func AnyStringToQuarterTime ¶
AnyStringToQuarterTime returns the current time if in the current quarter or the end of any previous quarter.
func DT14ForInts ¶ added in v0.46.0
DT14ForInts returns a Dt8 value for a UTC year, month, day, hour, minute and second.
func DT14ForString ¶ added in v0.46.0
DT14ForString returns a DT14 value given a layout and value to parse to time.Parse.
func DT6ForDT14 ¶ added in v0.46.0
DT6ForDT14 returns the Dt6 value for Dt14.
func DT6MinMaxSlice ¶ added in v0.46.0
func DaysAgoDowStrings ¶
func DaysToDowStrings ¶
func DurationDays ¶
func DurationDaysInt64 ¶
func DurationWeeks ¶ added in v0.53.0
func DurationYears ¶
func EqualQuarter ¶
func FirstDayOfISOWeek ¶
FirstDayOfISOWeek returns a time.Time object for the first day of a given ISO week. https://xferion.com/golang-reverse-isoweek-get-the-date-of-the-first-day-of-iso-week/
func FirstNonZeroTimeParsed ¶
func FormatDurationInfoMinSec ¶
func FormatDurationInfoMinSec(di DurationInfo) string
FormatDurationInfoMinSec returns the duration as a simple string like 01:01.
func FormatQuarter ¶
FormatQuarter takes quarter time and formats it using "Q# YYYY".
func FormatQuarterYYQ ¶
FormatQuarterYYQ takes quarter time and formats it using "'YY Q#".
func FormatQuarterYYYYQ ¶
FormatQuarter takes quarter time and formats it using "YYYY Q#".
func FormatTimeMulti ¶
FormatTimeMulti formats a `time.Time` object or an epoch number. It is adapted from `github.com/wcharczuk/go-chart`.
func FromToFirstValue ¶
func FromToFirstValueOrEmpty ¶
func GreaterTime ¶
GreaterTime returns the greater of two times.
func InQuarterRange ¶
InQuarterRange checks to see if the date is within 2 quarters.
func InQuarterTime ¶
func InRange ¶
InRange checks to see if a time is within a provided time range with options whether the start and end ranges are inclusive or exclusive. Exclusive ranges are the default.
func IntToBaseXString ¶
func IsDTX ¶ added in v0.50.0
IsDTX returns the dtx format if conformant to various DTX values (dt4, dt6, dt8, dt14).
func IsGreaterThan ¶
IsGreaterThan compares two times and returns true if the left time is greater than the right time.
func IsLessThan ¶
IsLessThan compares two times and returns true if the left time is less than the right time.
func IsQuarterInt32 ¶
func LesserTime ¶
LesserTime returns the lesser of two times.
func MinMaxInt32 ¶
func MonthNames ¶
func MonthNames() []string
func MonthToQuarter ¶
MonthToQuarter converts a month to a calendar quarter.
func MustInQuarterRange ¶
MustInQuarterRange returns whether a date is within 2 quarters. It panics if the quarter integer is not valid.
func MustParseDuration ¶
func NewDuration ¶ added in v0.45.0
func NewDurationFloat ¶ added in v0.51.0
func NumQuartersInt32 ¶
func OffsetFormat ¶
OffsetFormat converts an integer offset value to a string value to use in string time formats. Note: RFC-3339 times use colons and the UTC "Z" offset.
func ParseDuration ¶
ParseDuration adds days (d), weeks (w), years (y).
func ParseFirst ¶
ParseFirst attempts to parse a string with a set of layouts.
func ParseOrZero ¶
ParseOrZero returns a parsed time.Time or the RFC-3339 zero time.
func ParseTimeSQLTimestampUsingOffset ¶
ParseTimeSQLTimestampUsingOffset converts a SQL timestamp without timezone adding in a manual integer timezone.
func ParseTimeUsingOffset ¶
func QuarterInt32Add ¶ added in v0.40.1
func QuarterInt32ForTime ¶
func QuarterInt32Now ¶
func QuarterInt32Now() int32
func QuarterInt32Timeline ¶
func QuarterInt32ToYear ¶
func QuarterProjection ¶
QuarterProjection takes a time and numeric value, estimating the value at the end of the quarter using a straight-line projection.
func QuarterStartString ¶
func QuarterToMonth ¶
QuarterToMonth converts a calendar quarter to a month.
func QuartersInt32RelToAbs ¶
QuartersInt32RelToAbs is useful relative date queries.
func SliceMinMax ¶
SliceMinMax returns the min and max times of a time slice.
func SubDuration ¶
SubDuration subtracts one duration from another and returns the result as a `time.Duration`.
func TimeDT6AddNMonths ¶ added in v0.46.0
func TimeDeltaDow ¶
func TimeDeltaDowInt ¶
func TimeDeltaDowString ¶
func TimeForDT14 ¶ added in v0.46.0
TimeForDT14 returns a time.Time value given a Dt14 value.
func TimeForDT6 ¶ added in v0.46.0
TimeForDT6 returns a time.Time value given a Dt6 value.
func TimeMinRFC3339 ¶
func TimeSeriesMinMax ¶
TimeSeriesMinMax builds a time series based on supplied interval.
func TimeSeriesSlice ¶
TimeSeriesSlice builds a time series based on supplied interval.
func TimeZeroRFC3339 ¶
func TimeZeroUnix ¶
Types ¶
type DateTime8 ¶ added in v0.51.0
type DateTime8 uint32
DateTime8 represents a datetime `int32` value in the `yyyymmdd` format. It supports dates from 1000-01-01 to 9999-12-31.
func DT8ParseString ¶ added in v0.51.0
DT8ParseString returns a `DateTime8` value given a layout and value to parse to time.Parse.
func DT8ParseUints ¶ added in v0.51.0
DT8ParseUints returns a `DateTime8` value for year, month, and day.
func (DateTime8) SubTime ¶ added in v0.51.0
Sub returns the duration dt8-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute dt8-d for a duration d, use t.Add(-d).
func (*DateTime8) UnmarshalJSON ¶ added in v0.51.0
type DateTime8UnmarshalError ¶ added in v0.51.0
type DateTime8UnmarshalError struct {
Msg string
}
func (*DateTime8UnmarshalError) Error ¶ added in v0.51.0
func (e *DateTime8UnmarshalError) Error() string
type DurationInfo ¶
type DurationInfo struct { DaysPerWeek float32 HoursPerDay float32 Weeks int64 Days int64 Hours int64 Minutes int64 Seconds int64 Milliseconds int64 Microseconds int64 Nanoseconds int64 }
DurationInfo is a struct that holds integer values for each time unit including hours, minutes, seconds milliseconds, microseconds, and nanoseconds.
func NewDurationInfo ¶
func NewDurationInfo(d time.Duration, daysPerWeek, hoursPerDay float32) DurationInfo
NewDurationInfo returns a DurationInfo struct for a duration in nanos. If 'daysPerWeek` or `hoursPerDay` are set to zero, the default values of 7 and 24 are used.
func ParseDurationInfo ¶ added in v0.52.0
func ParseDurationInfo(s string) (DurationInfo, error)
ParseDurationInfo converts a Jira human readable string into a `DurationInfo` struct.
func (DurationInfo) Duration ¶
func (di DurationInfo) Duration(hoursPerDay, daysPerWeek float32) time.Duration
Duration returns a `time.Duration` struct. Params for `hoursPerDay` and `daysPerWeek` are used for atlernate values such as working hours per day and working days per week, e.g. 8 hours per day and 5 days per week.
type DurationInfoString ¶ added in v0.56.0
type DurationInfoString struct { DaysPerWeek float32 HoursPerDay float32 Weeks string Days string Hours string Minutes string Seconds string Milliseconds string Microseconds string Nanoseconds string }
DurationInfoString represets a set of time duration data. It is useful for converting parsed time data into a `time.Duration` struct. `DaysPerWeek` and `HoursPerDay` are provided as overrides to standard value of 7 and 24 in the case of business context, e.g. 5 days per week and 8 hours per day.
type DurationPct ¶
type DurationPct struct { DurationStartTime time.Time DurationEndTime time.Time DurationActive time.Duration DurationRange time.Duration DurationPct float64 }
func (*DurationPct) Inflate ¶
func (dp *DurationPct) Inflate() error
func (*DurationPct) InflateDurationActive ¶
func (dp *DurationPct) InflateDurationActive() error
type Event ¶
type Event struct { DurationPct DurationPct ImpactPct ImpactPct EventImpactPct float64 EventUptimePct float64 }
type ISO8601NoTzMilliTime ¶
func (ISO8601NoTzMilliTime) MarshalJSON ¶
func (t ISO8601NoTzMilliTime) MarshalJSON() ([]byte, error)
func (*ISO8601NoTzMilliTime) UnmarshalJSON ¶
func (t *ISO8601NoTzMilliTime) UnmarshalJSON(buf []byte) error
type QuarterTimeline ¶
type QuarterTimeline struct {
// contains filtered or unexported fields
}
func (*QuarterTimeline) Add ¶
func (qt *QuarterTimeline) Add(yyyyq int32)
func (*QuarterTimeline) AddInit ¶
func (qt *QuarterTimeline) AddInit(yyyyq int32)
func (*QuarterTimeline) Inflate ¶
func (qt *QuarterTimeline) Inflate() error
func (*QuarterTimeline) Timeline ¶
func (qt *QuarterTimeline) Timeline() ([]int32, error)
func (*QuarterTimeline) TimelineIndex ¶
func (qt *QuarterTimeline) TimelineIndex(yyyyq int32) (int, error)
type RFC3339YMDTime ¶
func (RFC3339YMDTime) MarshalJSON ¶
func (t RFC3339YMDTime) MarshalJSON() ([]byte, error)
func (*RFC3339YMDTime) UnmarshalJSON ¶
func (t *RFC3339YMDTime) UnmarshalJSON(buf []byte) error
type TimeMeta ¶
type TimeMeta struct { This time.Time WeekStartDay string YearStart time.Time YearEnd time.Time QuarterStart time.Time QuarterEnd time.Time MonthStart time.Time MonthEnd time.Time WeekStart time.Time WeekEnd time.Time DayStart time.Time DayEnd time.Time IsYearStart bool IsQuarterStart bool IsMonthStart bool }
TimeMeta is a struct for holding various times related to a current time, including year start, quarter start, month start, and week start.
type TimeMore ¶
type TimeMore struct {
// contains filtered or unexported fields
}
TimeMore is a struct for holding various times related to a current time, including year start, quarter start, month start, and week start.
func (TimeMore) IntervalStart ¶ added in v0.46.0
func (TimeMore) IsMonthStart ¶ added in v0.46.0
func (TimeMore) IsQuarterStart ¶ added in v0.46.0
func (TimeMore) IsYearStart ¶ added in v0.46.0
func (TimeMore) MonthStart ¶
func (TimeMore) QuarterDuration ¶ added in v0.46.0
QuarterDuration returns a `time.Duration` representing the calendar quarter for the time provided.
func (TimeMore) QuarterEnd ¶
func (TimeMore) QuarterStart ¶
func (TimeMore) TimeMeta ¶ added in v0.46.0
TimeMeta returns a TimeMeta struct given `time.Time` and `time.Weekday` parameters.
func (TimeMore) WeekStartDay ¶ added in v0.46.0
func (TimeMore) WeekdayNext ¶ added in v0.46.0
type TimeOpts ¶
type TimeOpts struct { Year int Month int Day int Hour int Minute int Second int Nanosecond int Location *time.Location }
TimeOpts represnts a struct for `time.Date`.
type TimeRange ¶
TimeRange represents a time range with a max and min value.
func (*TimeRange) HasIntersection ¶
func (*TimeRange) IntersectionDuration ¶
func (*TimeRange) Nanoseconds ¶
type TimeRanges ¶
type TimeRanges []*TimeRange
func (TimeRanges) FilterNonZero ¶
func (trs TimeRanges) FilterNonZero() TimeRanges
func (TimeRanges) IntersectionAny ¶
func (trs TimeRanges) IntersectionAny() time.Duration
type Times ¶ added in v0.46.0
Times is a slice of `time.Time` that supports a number of functions and can be used for sorting, e.g. `sort.Sort(times)` or `sort.Sort(sort.Reverse(times))`.
func (Times) RangeLower ¶ added in v0.46.0
RangeLower returns the TimeSlice time value for the range lower than or equal to the supplied time.
func (Times) RangeUpper ¶ added in v0.46.0
RangeUpper returns the Times time value for the range lower than or equal to the supplied time. The time `t` must be less than or equal to the upper range.
func (Times) SortReverse ¶ added in v0.46.0
func (ts Times) SortReverse()
Source Files ¶
- compare.go
- constants.go
- day.go
- dt8.go
- duration.go
- duration_info.go
- format.go
- interval.go
- month.go
- quarter.go
- quarter_int.go
- quarter_int_timeline.go
- slice.go
- start_end.go
- syscall.go
- time_range.go
- time_series.go
- timemore.go
- times.go
- timeutil.go
- timeutil_delta.go
- timeutil_projection.go
- uptime.go
- week.go
- xox_times.go