Documentation
¶
Index ¶
- Constants
- Variables
- func BeginningOfDay(t stdtime.Time) stdtime.Time
- func BeginningOfDayFromHasTime(hasTime HasTime) stdtime.Time
- func BeginningOfMonth(t stdtime.Time) stdtime.Time
- func BeginningOfMonthFromHasTime(hasTime HasTime) stdtime.Time
- func BeginningOfQuarter(t stdtime.Time) stdtime.Time
- func BeginningOfQuarterFromHasTime(hasTime HasTime) stdtime.Time
- func BeginningOfWeek(t stdtime.Time) stdtime.Time
- func BeginningOfWeekFromHasTime(hasTime HasTime) stdtime.Time
- func BeginningOfYear(t stdtime.Time) stdtime.Time
- func BeginningOfYearFromHasTime(hasTime HasTime) stdtime.Time
- func Compare(x, y time.Time) int
- func EndOfDay(t stdtime.Time) stdtime.Time
- func EndOfDayFromHasTime(hasTime HasTime) stdtime.Time
- func EndOfMonth(t stdtime.Time) stdtime.Time
- func EndOfMonthFromHasTime(hasTime HasTime) stdtime.Time
- func EndOfQuarter(t stdtime.Time) stdtime.Time
- func EndOfQuarterFromHasTime(hasTime HasTime) stdtime.Time
- func EndOfWeek(t stdtime.Time) stdtime.Time
- func EndOfWeekFromHasTime(hasTime HasTime) stdtime.Time
- func EndOfYear(t stdtime.Time) stdtime.Time
- func EndOfYearFromHasTime(hasTime HasTime) stdtime.Time
- func FormatTime(t *time.Time) string
- func HasEqualDate(t1, t2 time.Time) bool
- func LoadLocation(ctx context.Context, name string) (*stdtime.Location, error)
- func Max(a, b time.Time) time.Time
- func ParseLocation(ctx context.Context, value any) (*stdtime.Location, error)
- func ParseTime(ctx context.Context, value interface{}) (*stdtime.Time, error)
- func ParseTimeDefault(ctx context.Context, value interface{}, defaultValue stdtime.Time) stdtime.Time
- type CurrentDateTime
- type CurrentDateTimeGetter
- type CurrentDateTimeGetterFunc
- type CurrentDateTimeSetter
- type CurrentTime
- type CurrentTimeGetter
- type CurrentTimeGetterFunc
- type CurrentTimeSetter
- type Date
- func DateFromBinary(ctx context.Context, value []byte) (*Date, error)
- func DatePtr(value *stdtime.Time) *Date
- func NewDate(year int, month stdtime.Month, day, hour, min, sec, nsec int, ...) Date
- func ParseDate(ctx context.Context, value interface{}) (*Date, error)
- func ToDate(value stdtime.Time) Date
- func (d Date) Add(duration HasDuration) Date
- func (d Date) AddDate(years int, months int, days int) Date
- func (d Date) AddTime(years int, months int, days int) Datedeprecated
- func (d Date) After(other HasTime) bool
- func (d Date) Before(other HasTime) bool
- func (d Date) Clone() Date
- func (d *Date) ClonePtr() *Date
- func (d Date) Compare(stdTime Date) int
- func (d *Date) ComparePtr(stdTime *Date) int
- func (d Date) Day() int
- func (d Date) Equal(other Date) bool
- func (d *Date) EqualPtr(other *Date) bool
- func (d Date) Format(layout string) string
- func (d Date) IsZero() bool
- func (d Date) MarshalBinary() ([]byte, error)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) Month() stdtime.Month
- func (d Date) Ptr() *Date
- func (d Date) String() string
- func (d Date) Sub(time HasTime) Duration
- func (d Date) Time() stdtime.Time
- func (d *Date) TimePtr() *stdtime.Time
- func (d Date) Truncate(duration HasDuration) Date
- func (d Date) UTC() Date
- func (d Date) Unix() int64
- func (d Date) UnixMicro() int64
- func (d *Date) UnmarshalJSON(b []byte) error
- func (d *Date) UnmarshalText(b []byte) error
- func (d Date) Validate(ctx context.Context) error
- func (d Date) Weekday() Weekday
- func (d Date) Year() int
- type DateOrDateTime
- func DateOrDateTimeFromBinary(ctx context.Context, value []byte) (*DateOrDateTime, error)
- func DateOrDateTimePtr(value *stdtime.Time) *DateOrDateTime
- func NewDateOrDateTime(year int, month stdtime.Month, day, hour, min, sec, nsec int, ...) DateOrDateTime
- func ParseDateOrDateTime(ctx context.Context, value interface{}) (*DateOrDateTime, error)
- func ParseDateOrDateTimeDefault(ctx context.Context, value interface{}, defaultValue DateOrDateTime) DateOrDateTime
- func (d DateOrDateTime) Add(duration HasDuration) DateOrDateTime
- func (d DateOrDateTime) AddDate(years int, months int, days int) DateOrDateTime
- func (d DateOrDateTime) AddTime(years int, months int, days int) DateOrDateTimedeprecated
- func (d DateOrDateTime) After(other HasTime) bool
- func (d DateOrDateTime) AsDate() Date
- func (d DateOrDateTime) AsDateTime() DateTime
- func (d DateOrDateTime) Before(other HasTime) bool
- func (d DateOrDateTime) Clone() DateOrDateTime
- func (d *DateOrDateTime) ClonePtr() *DateOrDateTime
- func (d DateOrDateTime) Compare(other DateOrDateTime) int
- func (d *DateOrDateTime) ComparePtr(other *DateOrDateTime) int
- func (d DateOrDateTime) Day() int
- func (d DateOrDateTime) Equal(other DateOrDateTime) bool
- func (d *DateOrDateTime) EqualPtr(other *DateOrDateTime) bool
- func (d DateOrDateTime) Format(layout string) string
- func (d DateOrDateTime) Hour() int
- func (d DateOrDateTime) IsDateOnly() bool
- func (d DateOrDateTime) IsZero() bool
- func (d DateOrDateTime) MarshalBinary() ([]byte, error)
- func (d DateOrDateTime) MarshalJSON() ([]byte, error)
- func (d DateOrDateTime) MarshalText() ([]byte, error)
- func (d DateOrDateTime) Minute() int
- func (d DateOrDateTime) Month() stdtime.Month
- func (d DateOrDateTime) Nanosecond() int
- func (d DateOrDateTime) Ptr() *DateOrDateTime
- func (d DateOrDateTime) Second() int
- func (d DateOrDateTime) String() string
- func (d DateOrDateTime) Sub(other HasTime) Duration
- func (d DateOrDateTime) Time() stdtime.Time
- func (d *DateOrDateTime) TimePtr() *stdtime.Time
- func (d DateOrDateTime) Truncate(duration HasDuration) DateOrDateTime
- func (d DateOrDateTime) UTC() DateOrDateTime
- func (d DateOrDateTime) Unix() int64
- func (d DateOrDateTime) UnixMicro() int64
- func (d *DateOrDateTime) UnmarshalJSON(b []byte) error
- func (d *DateOrDateTime) UnmarshalText(b []byte) error
- func (d DateOrDateTime) Validate(ctx context.Context) error
- func (d DateOrDateTime) Weekday() Weekday
- func (d DateOrDateTime) Year() int
- type DateOrDateTimes
- type DateRange
- type DateRanges
- type DateTime
- func DateTimeFromBinary(ctx context.Context, value []byte) (*DateTime, error)
- func DateTimeFromUnixMicro(ms int64) DateTime
- func DateTimePtr(time *stdtime.Time) *DateTime
- func NewDateTime(year int, month stdtime.Month, day, hour, min, sec, nsec int, ...) DateTime
- func ParseDateTime(ctx context.Context, value interface{}) (*DateTime, error)
- func ParseDateTimeDefault(ctx context.Context, value interface{}, defaultValue DateTime) DateTime
- func (d DateTime) Add(duration HasDuration) DateTime
- func (d DateTime) AddDate(years int, months int, days int) DateTime
- func (d DateTime) AddTime(years int, months int, days int) DateTimedeprecated
- func (d DateTime) After(time HasTime) bool
- func (d DateTime) Before(time HasTime) bool
- func (d DateTime) Clone() DateTime
- func (d *DateTime) ClonePtr() *DateTime
- func (d DateTime) Compare(stdTime DateTime) int
- func (d *DateTime) ComparePtr(stdTime *DateTime) int
- func (d DateTime) Day() int
- func (d DateTime) Equal(stdTime DateTime) bool
- func (d *DateTime) EqualPtr(stdTime *DateTime) bool
- func (d DateTime) Format(layout string) string
- func (d DateTime) Hour() int
- func (d DateTime) IsZero() bool
- func (d DateTime) MarshalBinary() ([]byte, error)
- func (d DateTime) MarshalJSON() ([]byte, error)
- func (d DateTime) MarshalText() ([]byte, error)
- func (d DateTime) Minute() int
- func (d DateTime) Month() stdtime.Month
- func (d DateTime) Nanosecond() int
- func (d DateTime) Ptr() *DateTime
- func (d DateTime) Second() int
- func (d DateTime) String() string
- func (d DateTime) Sub(time HasTime) Duration
- func (d DateTime) Time() stdtime.Time
- func (d *DateTime) TimePtr() *stdtime.Time
- func (d DateTime) Truncate(duration HasDuration) DateTime
- func (d DateTime) UTC() DateTime
- func (d DateTime) Unix() int64
- func (d DateTime) UnixMicro() int64
- func (d *DateTime) UnmarshalJSON(b []byte) error
- func (d *DateTime) UnmarshalText(b []byte) error
- func (d DateTime) Validate(ctx context.Context) error
- func (d DateTime) Weekday() Weekday
- func (d DateTime) Year() int
- type DateTimeRange
- func DateTimeRangeFromTime(from, until stdtime.Time) DateTimeRange
- func DayDateTimeRange(dt DateTime) DateTimeRange
- func MonthDateTimeRange(dt DateTime) DateTimeRange
- func QuarterDateTimeRange(dt DateTime) DateTimeRange
- func WeekDateTimeRange(dt DateTime) DateTimeRange
- func YearDateTimeRange(dt DateTime) DateTimeRange
- type DateTimeRanges
- type DateTimes
- type Dates
- type Duration
- func (d Duration) Abs() Duration
- func (d Duration) Duration() stdtime.Duration
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d Duration) MarshalText() ([]byte, error)
- func (d Duration) Ptr() *Duration
- func (d Duration) String() string
- func (d *Duration) UnmarshalJSON(b []byte) error
- func (d *Duration) UnmarshalText(b []byte) error
- type Durations
- type HasDuration
- type HasTime
- type Layout
- type Layouts
- type TimeOfDay
- func (t TimeOfDay) After(stdTime TimeOfDay) bool
- func (t TimeOfDay) Before(stdTime TimeOfDay) bool
- func (t TimeOfDay) Date(year int, month stdtime.Month, day int) (*stdtime.Time, error)
- func (t TimeOfDay) DateTime(year int, month stdtime.Month, day int) DateTime
- func (t TimeOfDay) Equal(stdTime TimeOfDay) bool
- func (t TimeOfDay) Format(layout string) string
- func (t TimeOfDay) MarshalJSON() ([]byte, error)
- func (t TimeOfDay) MarshalText() ([]byte, error)
- func (t TimeOfDay) Ptr() *TimeOfDay
- func (t TimeOfDay) String() string
- func (t TimeOfDay) Time(year int, month stdtime.Month, day int) stdtime.Time
- func (t *TimeOfDay) UnmarshalJSON(b []byte) error
- func (t *TimeOfDay) UnmarshalText(b []byte) error
- type TimeOfDays
- type TimeRange
- type UnixTime
- func NewUnixTime(year int, month stdtime.Month, day, hour, min, sec, nsec int, ...) UnixTime
- func ParseUnixTime(ctx context.Context, value interface{}) (*UnixTime, error)
- func ParseUnixTimeDefault(ctx context.Context, value interface{}, defaultValue UnixTime) UnixTime
- func UnixTimeFromBinary(ctx context.Context, value []byte) (*UnixTime, error)
- func UnixTimeFromMicro(usec int64) UnixTime
- func UnixTimeFromMilli(msec int64) UnixTime
- func UnixTimeFromSeconds(seconds int64) UnixTime
- func UnixTimePtr(time *stdtime.Time) *UnixTime
- func (u UnixTime) Add(duration HasDuration) UnixTime
- func (u UnixTime) AddDate(years int, months int, days int) UnixTime
- func (u UnixTime) AddTime(years int, months int, days int) UnixTimedeprecated
- func (u UnixTime) After(time HasTime) bool
- func (u UnixTime) Before(time HasTime) bool
- func (u UnixTime) Clone() UnixTime
- func (u *UnixTime) ClonePtr() *UnixTime
- func (u UnixTime) Compare(other UnixTime) int
- func (u *UnixTime) ComparePtr(other *UnixTime) int
- func (u UnixTime) DateTime() DateTime
- func (u UnixTime) Day() int
- func (u UnixTime) Equal(unixTime UnixTime) bool
- func (u *UnixTime) EqualPtr(unixTime *UnixTime) bool
- func (u UnixTime) Format(layout string) string
- func (u UnixTime) Hour() int
- func (u UnixTime) IsZero() bool
- func (u UnixTime) MarshalBinary() ([]byte, error)
- func (u UnixTime) MarshalJSON() ([]byte, error)
- func (u UnixTime) MarshalText() ([]byte, error)
- func (u UnixTime) Minute() int
- func (u UnixTime) Month() stdtime.Month
- func (u UnixTime) Nanosecond() int
- func (u UnixTime) Ptr() *UnixTime
- func (u UnixTime) Second() int
- func (u UnixTime) String() string
- func (u UnixTime) Sub(time HasTime) Duration
- func (u UnixTime) Time() stdtime.Time
- func (u *UnixTime) TimePtr() *stdtime.Time
- func (u UnixTime) Truncate(duration HasDuration) UnixTime
- func (u UnixTime) UTC() UnixTime
- func (u UnixTime) Unix() int64
- func (u UnixTime) UnixMicro() int64
- func (u *UnixTime) UnmarshalJSON(b []byte) error
- func (u *UnixTime) UnmarshalText(b []byte) error
- func (u UnixTime) Validate(ctx context.Context) error
- func (u UnixTime) Weekday() Weekday
- func (u UnixTime) Year() int
- type UnixTimeRange
- func DayUnixTimeRange(ut UnixTime) UnixTimeRange
- func MonthUnixTimeRange(ut UnixTime) UnixTimeRange
- func QuarterUnixTimeRange(ut UnixTime) UnixTimeRange
- func UnixTimeRangeFromTime(from, until stdtime.Time) UnixTimeRange
- func WeekUnixTimeRange(ut UnixTime) UnixTimeRange
- func YearUnixTimeRange(ut UnixTime) UnixTimeRange
- type UnixTimeRanges
- type UnixTimes
- type WaiterDuration
- type WaiterDurationFunc
- type WaiterUntil
- type WaiterUntilFunc
- type Weekday
- type Weekdays
Constants ¶
const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Millisecond Minute = 60 * Second Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day )
const TimeOfDayLayout = "15:04:05.999999999Z07:00"
Variables ¶
var AvailableWeekdays = Weekdays{ Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, }
var Now = time.Now
Now allow to modify now, please use CurrentTime if possible
var UnitMap = map[string]Duration{ "ns": Nanosecond, "us": Microsecond, "ms": Millisecond, "s": Second, "m": Minute, "h": Hour, "d": Day, "w": Week, }
UnitMap contains units to duration mapping
Functions ¶
func BeginningOfDay ¶
BeginningOfDay returns the start of the day (00:00:00.000000000) for the given time. Preserves the original timezone.
func BeginningOfDayFromHasTime ¶
BeginningOfDayFromHasTime returns the start of the day for any type implementing HasTime interface.
func BeginningOfMonth ¶
BeginningOfMonth returns the start of the month (1st day 00:00:00.000000000) for the given time. Preserves the original timezone.
func BeginningOfMonthFromHasTime ¶
BeginningOfMonthFromHasTime returns the start of the month for any type implementing HasTime interface.
func BeginningOfQuarter ¶
BeginningOfQuarter returns the start of the quarter (1st day of quarter 00:00:00.000000000) for the given time. Quarters are: Q1=Jan-Mar, Q2=Apr-Jun, Q3=Jul-Sep, Q4=Oct-Dec. Preserves the original timezone.
func BeginningOfQuarterFromHasTime ¶
BeginningOfQuarterFromHasTime returns the start of the quarter for any type implementing HasTime interface.
func BeginningOfWeek ¶
BeginningOfWeek returns the start of the week (Monday 00:00:00.000000000) for the given time. Uses ISO 8601 standard where Monday is the first day of the week. Preserves the original timezone.
func BeginningOfWeekFromHasTime ¶
BeginningOfWeekFromHasTime returns the start of the week for any type implementing HasTime interface.
func BeginningOfYear ¶
BeginningOfYear returns the start of the year (January 1st 00:00:00.000000000) for the given time. Preserves the original timezone.
func BeginningOfYearFromHasTime ¶
BeginningOfYearFromHasTime returns the start of the year for any type implementing HasTime interface.
func EndOfDay ¶
EndOfDay returns the end of the day (23:59:59.999999999) for the given time. This is calculated as the start of the next day minus 1 nanosecond.
func EndOfDayFromHasTime ¶
EndOfDayFromHasTime returns the end of the day for any type implementing HasTime interface.
func EndOfMonth ¶
EndOfMonth returns the end of the month (last day 23:59:59.999999999) for the given time. This is calculated as the start of the next month minus 1 nanosecond.
func EndOfMonthFromHasTime ¶
EndOfMonthFromHasTime returns the end of the month for any type implementing HasTime interface.
func EndOfQuarter ¶
EndOfQuarter returns the end of the quarter (last day of quarter 23:59:59.999999999) for the given time. This is calculated as the start of the next quarter minus 1 nanosecond.
func EndOfQuarterFromHasTime ¶
EndOfQuarterFromHasTime returns the end of the quarter for any type implementing HasTime interface.
func EndOfWeek ¶
EndOfWeek returns the end of the week (Sunday 23:59:59.999999999) for the given time. This is calculated as the start of the next week minus 1 nanosecond.
func EndOfWeekFromHasTime ¶
EndOfWeekFromHasTime returns the end of the week for any type implementing HasTime interface.
func EndOfYear ¶
EndOfYear returns the end of the year (December 31st 23:59:59.999999999) for the given time. This is calculated as the start of the next year minus 1 nanosecond.
func EndOfYearFromHasTime ¶
EndOfYearFromHasTime returns the end of the year for any type implementing HasTime interface.
func FormatTime ¶
func HasEqualDate ¶
Types ¶
type CurrentDateTime ¶
type CurrentDateTime interface {
CurrentDateTimeGetter
CurrentDateTimeSetter
}
func NewCurrentDateTime ¶
func NewCurrentDateTime() CurrentDateTime
type CurrentDateTimeGetter ¶
type CurrentDateTimeGetter interface {
Now() DateTime
}
type CurrentDateTimeGetterFunc ¶
type CurrentDateTimeGetterFunc func() DateTime
func (CurrentDateTimeGetterFunc) Now ¶
func (c CurrentDateTimeGetterFunc) Now() DateTime
type CurrentDateTimeSetter ¶
type CurrentDateTimeSetter interface {
SetNow(now DateTime)
}
type CurrentTime ¶
type CurrentTime interface {
CurrentTimeGetter
CurrentTimeSetter
}
func NewCurrentTime ¶
func NewCurrentTime() CurrentTime
type CurrentTimeGetter ¶
type CurrentTimeGetterFunc ¶
type CurrentTimeGetterFunc func() DateTime
func (CurrentTimeGetterFunc) Now ¶
func (c CurrentTimeGetterFunc) Now() DateTime
type CurrentTimeSetter ¶
type Date ¶
func NewDate ¶
func NewDate( year int, month stdtime.Month, day, hour, min, sec, nsec int, loc *stdtime.Location, ) Date
NewDate creates a Date representing the date specified by the given parameters. It wraps the standard library's time.Date function with the same parameter signature. Note: hour, min, sec, nsec and loc parameters are typically ignored for Date operations.
func (Date) Add ¶
func (d Date) Add(duration HasDuration) Date
func (*Date) ComparePtr ¶
func (Date) MarshalBinary ¶
func (Date) MarshalJSON ¶
func (Date) MarshalText ¶
func (Date) Truncate ¶
func (d Date) Truncate(duration HasDuration) Date
func (*Date) UnmarshalJSON ¶
func (*Date) UnmarshalText ¶
type DateOrDateTime ¶
func DateOrDateTimeFromBinary ¶
func DateOrDateTimeFromBinary(ctx context.Context, value []byte) (*DateOrDateTime, error)
func DateOrDateTimePtr ¶
func DateOrDateTimePtr(value *stdtime.Time) *DateOrDateTime
func NewDateOrDateTime ¶
func NewDateOrDateTime( year int, month stdtime.Month, day, hour, min, sec, nsec int, loc *stdtime.Location, ) DateOrDateTime
NewDateOrDateTime creates a DateOrDateTime representing the date and time specified by the given parameters. It wraps the standard library's time.Date function with the same parameter signature.
func ParseDateOrDateTime ¶
func ParseDateOrDateTime(ctx context.Context, value interface{}) (*DateOrDateTime, error)
func ParseDateOrDateTimeDefault ¶
func ParseDateOrDateTimeDefault( ctx context.Context, value interface{}, defaultValue DateOrDateTime, ) DateOrDateTime
func (DateOrDateTime) Add ¶
func (d DateOrDateTime) Add(duration HasDuration) DateOrDateTime
func (DateOrDateTime) AddDate ¶
func (d DateOrDateTime) AddDate(years int, months int, days int) DateOrDateTime
func (DateOrDateTime) AddTime
deprecated
func (d DateOrDateTime) AddTime(years int, months int, days int) DateOrDateTime
Deprecated: Use AddDate instead. AddTime adds the given years, months, and days to the DateOrDateTime but will be removed in future versions.
func (DateOrDateTime) After ¶
func (d DateOrDateTime) After(other HasTime) bool
func (DateOrDateTime) AsDate ¶
func (d DateOrDateTime) AsDate() Date
AsDate returns the date component of d as a Date value.
func (DateOrDateTime) AsDateTime ¶
func (d DateOrDateTime) AsDateTime() DateTime
AsDateTime returns d as a DateTime value.
func (DateOrDateTime) Before ¶
func (d DateOrDateTime) Before(other HasTime) bool
func (DateOrDateTime) Clone ¶
func (d DateOrDateTime) Clone() DateOrDateTime
func (*DateOrDateTime) ClonePtr ¶
func (d *DateOrDateTime) ClonePtr() *DateOrDateTime
func (DateOrDateTime) Compare ¶
func (d DateOrDateTime) Compare(other DateOrDateTime) int
func (*DateOrDateTime) ComparePtr ¶
func (d *DateOrDateTime) ComparePtr(other *DateOrDateTime) int
func (DateOrDateTime) Day ¶
func (d DateOrDateTime) Day() int
func (DateOrDateTime) Equal ¶
func (d DateOrDateTime) Equal(other DateOrDateTime) bool
func (*DateOrDateTime) EqualPtr ¶
func (d *DateOrDateTime) EqualPtr(other *DateOrDateTime) bool
func (DateOrDateTime) Format ¶
func (d DateOrDateTime) Format(layout string) string
func (DateOrDateTime) Hour ¶
func (d DateOrDateTime) Hour() int
func (DateOrDateTime) IsDateOnly ¶
func (d DateOrDateTime) IsDateOnly() bool
IsDateOnly reports whether d represents a date-only value (midnight UTC).
func (DateOrDateTime) IsZero ¶
func (d DateOrDateTime) IsZero() bool
IsZero reports whether d represents the zero time instant.
func (DateOrDateTime) MarshalBinary ¶
func (d DateOrDateTime) MarshalBinary() ([]byte, error)
func (DateOrDateTime) MarshalJSON ¶
func (d DateOrDateTime) MarshalJSON() ([]byte, error)
func (DateOrDateTime) MarshalText ¶
func (d DateOrDateTime) MarshalText() ([]byte, error)
func (DateOrDateTime) Minute ¶
func (d DateOrDateTime) Minute() int
func (DateOrDateTime) Month ¶
func (d DateOrDateTime) Month() stdtime.Month
func (DateOrDateTime) Nanosecond ¶
func (d DateOrDateTime) Nanosecond() int
func (DateOrDateTime) Ptr ¶
func (d DateOrDateTime) Ptr() *DateOrDateTime
func (DateOrDateTime) Second ¶
func (d DateOrDateTime) Second() int
func (DateOrDateTime) String ¶
func (d DateOrDateTime) String() string
func (DateOrDateTime) Sub ¶
func (d DateOrDateTime) Sub(other HasTime) Duration
func (DateOrDateTime) Time ¶
func (d DateOrDateTime) Time() stdtime.Time
func (*DateOrDateTime) TimePtr ¶
func (d *DateOrDateTime) TimePtr() *stdtime.Time
func (DateOrDateTime) Truncate ¶
func (d DateOrDateTime) Truncate(duration HasDuration) DateOrDateTime
func (DateOrDateTime) UTC ¶
func (d DateOrDateTime) UTC() DateOrDateTime
func (DateOrDateTime) Unix ¶
func (d DateOrDateTime) Unix() int64
func (DateOrDateTime) UnixMicro ¶
func (d DateOrDateTime) UnixMicro() int64
func (*DateOrDateTime) UnmarshalJSON ¶
func (d *DateOrDateTime) UnmarshalJSON(b []byte) error
func (*DateOrDateTime) UnmarshalText ¶
func (d *DateOrDateTime) UnmarshalText(b []byte) error
func (DateOrDateTime) Weekday ¶
func (d DateOrDateTime) Weekday() Weekday
func (DateOrDateTime) Year ¶
func (d DateOrDateTime) Year() int
type DateOrDateTimes ¶
type DateOrDateTimes []DateOrDateTime
func (DateOrDateTimes) Interfaces ¶
func (d DateOrDateTimes) Interfaces() []interface{}
func (DateOrDateTimes) Strings ¶
func (d DateOrDateTimes) Strings() []string
type DateRange ¶
func DateRangeFromTime ¶
DateRangeFromTime creates a DateRange from two time.Time values. It converts the from and until times to Date types and returns a DateRange.
func DayDateRange ¶
DayDateRange creates a DateRange covering the entire day containing the given date. The range spans from 00:00:00.000000000 to 23:59:59.999999999 of that day.
func MonthDateRange ¶
MonthDateRange creates a DateRange covering the entire month containing the given date. The range spans from the 1st day to the last day of that month.
func QuarterDateRange ¶
QuarterDateRange creates a DateRange covering the entire quarter containing the given date. Quarters are defined as: Q1=Jan-Mar, Q2=Apr-Jun, Q3=Jul-Sep, Q4=Oct-Dec. The range spans from the 1st day of the quarter to the last day of that quarter.
func WeekDateRange ¶
WeekDateRange creates a DateRange covering the entire week containing the given date. The range spans from Monday to Sunday of that week. Uses ISO 8601 standard where Monday is the first day of the week.
func YearDateRange ¶
YearDateRange creates a DateRange covering the entire year containing the given date. The range spans from January 1st to December 31st of that year.
type DateRanges ¶
type DateRanges []DateRange
func (DateRanges) Max ¶
func (ranges DateRanges) Max() *DateRange
Max returns the maximum DateRange that encompasses all ranges in the list. It finds the earliest From date and the latest Until date across all ranges. Returns nil if the list is empty.
func (DateRanges) Min ¶
func (ranges DateRanges) Min() *DateRange
Min returns the minimum DateRange that is contained within all ranges in the list. It finds the latest From date and the earliest Until date across all ranges. Returns nil if the list is empty or if there is no overlap between ranges.
type DateTime ¶
func DateTimeFromBinary ¶
func DateTimeFromUnixMicro ¶
func DateTimePtr ¶
func NewDateTime ¶
func NewDateTime( year int, month stdtime.Month, day, hour, min, sec, nsec int, loc *stdtime.Location, ) DateTime
NewDateTime creates a DateTime representing the date and time specified by the given parameters. It wraps the standard library's time.Date function with the same parameter signature.
func ParseDateTimeDefault ¶
func (DateTime) Add ¶
func (d DateTime) Add(duration HasDuration) DateTime
func (*DateTime) ComparePtr ¶
func (DateTime) MarshalBinary ¶
func (DateTime) MarshalJSON ¶
func (DateTime) MarshalText ¶
func (DateTime) Nanosecond ¶
func (DateTime) Truncate ¶
func (d DateTime) Truncate(duration HasDuration) DateTime
func (*DateTime) UnmarshalJSON ¶
func (*DateTime) UnmarshalText ¶
type DateTimeRange ¶
type DateTimeRange struct {
From DateTime `json:"from,omitempty"`
Until DateTime `json:"until,omitempty"`
}
func DateTimeRangeFromTime ¶
func DateTimeRangeFromTime(from, until stdtime.Time) DateTimeRange
DateTimeRangeFromTime creates a DateTimeRange from two time.Time values. It converts the from and until times to DateTime types and returns a DateTimeRange.
func DayDateTimeRange ¶
func DayDateTimeRange(dt DateTime) DateTimeRange
DayDateTimeRange creates a DateTimeRange covering the entire day containing the given datetime. The range spans from 00:00:00.000000000 to 23:59:59.999999999 of that day.
func MonthDateTimeRange ¶
func MonthDateTimeRange(dt DateTime) DateTimeRange
MonthDateTimeRange creates a DateTimeRange covering the entire month containing the given datetime. The range spans from the 1st day 00:00:00.000000000 to the last day 23:59:59.999999999 of that month.
func QuarterDateTimeRange ¶
func QuarterDateTimeRange(dt DateTime) DateTimeRange
QuarterDateTimeRange creates a DateTimeRange covering the entire quarter containing the given datetime. Quarters are defined as: Q1=Jan-Mar, Q2=Apr-Jun, Q3=Jul-Sep, Q4=Oct-Dec. The range spans from the 1st day of the quarter 00:00:00.000000000 to the last day 23:59:59.999999999 of that quarter.
func WeekDateTimeRange ¶
func WeekDateTimeRange(dt DateTime) DateTimeRange
WeekDateTimeRange creates a DateTimeRange covering the entire week containing the given datetime. The range spans from Monday 00:00:00.000000000 to Sunday 23:59:59.999999999 of that week. Uses ISO 8601 standard where Monday is the first day of the week.
func YearDateTimeRange ¶
func YearDateTimeRange(dt DateTime) DateTimeRange
YearDateTimeRange creates a DateTimeRange covering the entire year containing the given datetime. The range spans from January 1st 00:00:00.000000000 to December 31st 23:59:59.999999999 of that year.
func (DateTimeRange) Ptr ¶
func (r DateTimeRange) Ptr() *DateTimeRange
func (DateTimeRange) TimeRange ¶
func (r DateTimeRange) TimeRange() TimeRange
TimeRange converts a DateTimeRange to a TimeRange.
type DateTimeRanges ¶
type DateTimeRanges []DateTimeRange
func (DateTimeRanges) Max ¶
func (ranges DateTimeRanges) Max() *DateTimeRange
Max returns the maximum DateTimeRange that encompasses all ranges in the list. It finds the earliest From time and the latest Until time across all ranges. Returns nil if the list is empty.
func (DateTimeRanges) Min ¶
func (ranges DateTimeRanges) Min() *DateTimeRange
Min returns the minimum DateTimeRange that is contained within all ranges in the list. It finds the latest From time and the earliest Until time across all ranges. Returns nil if the list is empty or if there is no overlap between ranges.
type DateTimes ¶
type DateTimes []DateTime
func (DateTimes) Interfaces ¶
func (t DateTimes) Interfaces() []interface{}
type Duration ¶
func DurationPtr ¶
func ParseDurationDefault ¶
func (Duration) MarshalJSON ¶
func (Duration) MarshalText ¶
func (*Duration) UnmarshalJSON ¶
func (*Duration) UnmarshalText ¶
type Durations ¶
type Durations []Duration
func (Durations) Interfaces ¶
func (t Durations) Interfaces() []interface{}
type HasDuration ¶
type Layout ¶
type Layout string
Layout is one of (millis,seconds,nano) or any time.Layout like time.RFC3339Nano
type TimeOfDay ¶
func ParseTimeOfDay ¶
func ParseTimeOfDayDefault ¶
func TimeOfDayFromTime ¶
func (TimeOfDay) MarshalJSON ¶
func (TimeOfDay) MarshalText ¶
func (*TimeOfDay) UnmarshalJSON ¶
func (*TimeOfDay) UnmarshalText ¶
type TimeOfDays ¶
type TimeOfDays []TimeOfDay
func (TimeOfDays) Interfaces ¶
func (t TimeOfDays) Interfaces() []interface{}
func (TimeOfDays) Strings ¶
func (t TimeOfDays) Strings() []string
type TimeRange ¶
type TimeRange struct {
From stdtime.Time `json:"from,omitempty"`
Until stdtime.Time `json:"until,omitempty"`
}
func DayTimeRange ¶
DayTimeRange creates a TimeRange covering the entire day containing the given time. The range spans from 00:00:00.000000000 to 23:59:59.999999999 of that day.
func MonthTimeRange ¶
MonthTimeRange creates a TimeRange covering the entire month containing the given time. The range spans from the 1st day 00:00:00.000000000 to the last day 23:59:59.999999999 of that month.
func QuarterTimeRange ¶
QuarterTimeRange creates a TimeRange covering the entire quarter containing the given time. Quarters are defined as: Q1=Jan-Mar, Q2=Apr-Jun, Q3=Jul-Sep, Q4=Oct-Dec. The range spans from the 1st day of the quarter to the last day 23:59:59.999999999 of that quarter.
func WeekTimeRange ¶
WeekTimeRange creates a TimeRange covering the entire week containing the given time. The range spans from Monday 00:00:00.000000000 to Sunday 23:59:59.999999999 of that week. Uses ISO 8601 standard where Monday is the first day of the week.
func YearTimeRange ¶
YearTimeRange creates a TimeRange covering the entire year containing the given time. The range spans from January 1st 00:00:00.000000000 to December 31st 23:59:59.999999999 of that year.
type UnixTime ¶
func NewUnixTime ¶
func NewUnixTime( year int, month stdtime.Month, day, hour, min, sec, nsec int, loc *stdtime.Location, ) UnixTime
NewUnixTime creates a UnixTime representing the date and time specified by the given parameters. It wraps the standard library's time.Date function with the same parameter signature.
func ParseUnixTimeDefault ¶
func UnixTimeFromBinary ¶
func UnixTimeFromMicro ¶
func UnixTimeFromMilli ¶
func UnixTimeFromSeconds ¶
func UnixTimePtr ¶
func (UnixTime) Add ¶
func (u UnixTime) Add(duration HasDuration) UnixTime
func (*UnixTime) ComparePtr ¶
func (UnixTime) MarshalBinary ¶
func (UnixTime) MarshalJSON ¶
func (UnixTime) MarshalText ¶
func (UnixTime) Nanosecond ¶
func (UnixTime) Truncate ¶
func (u UnixTime) Truncate(duration HasDuration) UnixTime
func (*UnixTime) UnmarshalJSON ¶
func (*UnixTime) UnmarshalText ¶
type UnixTimeRange ¶
type UnixTimeRange struct {
From UnixTime `json:"from,omitempty"`
Until UnixTime `json:"until,omitempty"`
}
func DayUnixTimeRange ¶
func DayUnixTimeRange(ut UnixTime) UnixTimeRange
DayUnixTimeRange creates a UnixTimeRange covering the entire day containing the given unix time. The range spans from 00:00:00.000000000 to 23:59:59.999999999 of that day.
func MonthUnixTimeRange ¶
func MonthUnixTimeRange(ut UnixTime) UnixTimeRange
MonthUnixTimeRange creates a UnixTimeRange covering the entire month containing the given unix time. The range spans from the 1st day 00:00:00.000000000 to the last day 23:59:59.999999999 of that month.
func QuarterUnixTimeRange ¶
func QuarterUnixTimeRange(ut UnixTime) UnixTimeRange
QuarterUnixTimeRange creates a UnixTimeRange covering the entire quarter containing the given unix time. Quarters are defined as: Q1=Jan-Mar, Q2=Apr-Jun, Q3=Jul-Sep, Q4=Oct-Dec. The range spans from the 1st day of the quarter 00:00:00.000000000 to the last day 23:59:59.999999999 of that quarter.
func UnixTimeRangeFromTime ¶
func UnixTimeRangeFromTime(from, until stdtime.Time) UnixTimeRange
UnixTimeRangeFromTime creates a UnixTimeRange from two time.Time values. It converts the from and until times to UnixTime types and returns a UnixTimeRange.
func WeekUnixTimeRange ¶
func WeekUnixTimeRange(ut UnixTime) UnixTimeRange
WeekUnixTimeRange creates a UnixTimeRange covering the entire week containing the given unix time. The range spans from Monday 00:00:00.000000000 to Sunday 23:59:59.999999999 of that week. Uses ISO 8601 standard where Monday is the first day of the week.
func YearUnixTimeRange ¶
func YearUnixTimeRange(ut UnixTime) UnixTimeRange
YearUnixTimeRange creates a UnixTimeRange covering the entire year containing the given unix time. The range spans from January 1st 00:00:00.000000000 to December 31st 23:59:59.999999999 of that year.
func (UnixTimeRange) Ptr ¶
func (r UnixTimeRange) Ptr() *UnixTimeRange
func (UnixTimeRange) TimeRange ¶
func (r UnixTimeRange) TimeRange() TimeRange
TimeRange converts a UnixTimeRange to a TimeRange.
type UnixTimeRanges ¶
type UnixTimeRanges []UnixTimeRange
func (UnixTimeRanges) Max ¶
func (ranges UnixTimeRanges) Max() *UnixTimeRange
Max returns the maximum UnixTimeRange that encompasses all ranges in the list. It finds the earliest From time and the latest Until time across all ranges. Returns nil if the list is empty.
func (UnixTimeRanges) Min ¶
func (ranges UnixTimeRanges) Min() *UnixTimeRange
Min returns the minimum UnixTimeRange that is contained within all ranges in the list. It finds the latest From time and the earliest Until time across all ranges. Returns nil if the list is empty or if there is no overlap between ranges.
type UnixTimes ¶
type UnixTimes []UnixTime
func (UnixTimes) Interfaces ¶
func (t UnixTimes) Interfaces() []interface{}
type WaiterDuration ¶
func NewWaiterDuration ¶
func NewWaiterDuration() WaiterDuration
type WaiterDurationFunc ¶
type WaiterUntil ¶
func NewWaiterUntil ¶
func NewWaiterUntil(currentDateTime CurrentDateTimeGetter) WaiterUntil
type WaiterUntilFunc ¶
Source Files
¶
- time_compare.go
- time_current-datetime.go
- time_current-time.go
- time_date-or-date-time.go
- time_date-range.go
- time_date-time-range.go
- time_date-time.go
- time_date.go
- time_duration.go
- time_equal-date.go
- time_format.go
- time_has-duration.go
- time_has-hime.go
- time_layout.go
- time_max.go
- time_now.go
- time_parse-time.go
- time_period-boundaries.go
- time_range.go
- time_time-of-day.go
- time_timezone.go
- time_unix-time-range.go
- time_unix-time.go
- time_waiter-duration.go
- time_waiter-until.go
- time_weekday.go