Documentation ¶
Index ¶
- func AddClock(t time.Time, c Clock) time.Time
- func HoursBetween(a, b time.Time) int
- func NextWeekday(t time.Time, w time.Weekday) time.Time
- func PrevWeekday(t time.Time, w time.Weekday) time.Time
- func StartOfDay(t time.Time) time.Time
- type Clock
- func (c Clock) Days() (int, Clock)
- func (c Clock) FirstOfDay(t time.Time) time.Time
- func (c Clock) Format(layout string) string
- func (c Clock) Hour() int
- func (c Clock) Is(t time.Time) bool
- func (c Clock) LastOfDay(t time.Time) time.Time
- func (c Clock) MarshalGQL(w io.Writer)
- func (c Clock) MarshalText() ([]byte, error)
- func (c Clock) Minute() int
- func (c *Clock) Scan(value interface{}) error
- func (c Clock) String() string
- func (c *Clock) UnmarshalGQL(v interface{}) error
- func (c *Clock) UnmarshalText(data []byte) error
- func (c Clock) Value() (driver.Value, error)
- type ISODuration
- func (dur ISODuration) AddTo(t time.Time) time.Time
- func (dur ISODuration) Days() int
- func (dur ISODuration) Equal(t time.Time, other ISODuration) bool
- func (dur ISODuration) IsZero() bool
- func (dur ISODuration) LessThan(t time.Time, other ISODuration) bool
- func (dur ISODuration) MarshalGQL(w io.Writer)
- func (dur *ISODuration) SetTimePart(timeDur time.Duration)
- func (dur ISODuration) String() string
- func (dur ISODuration) TimePart() time.Duration
- func (dur *ISODuration) UnmarshalGQL(v interface{}) error
- type ISORInterval
- type WeekdayFilter
- func (f WeekdayFilter) Day(d time.Weekday) bool
- func (f WeekdayFilter) DaysSince(d time.Weekday, enabled bool) int
- func (f WeekdayFilter) DaysUntil(d time.Weekday, enabled bool) int
- func (f WeekdayFilter) IsAlways() bool
- func (f WeekdayFilter) IsNever() bool
- func (f WeekdayFilter) MarshalGQL(w io.Writer)
- func (f WeekdayFilter) MarshalText() ([]byte, error)
- func (f WeekdayFilter) NextActive(t time.Time) time.Time
- func (f WeekdayFilter) NextInactive(t time.Time) time.Time
- func (f *WeekdayFilter) Scan(src interface{}) error
- func (f *WeekdayFilter) SetDay(d time.Weekday, enabled bool)
- func (f WeekdayFilter) StartTime(t time.Time) time.Time
- func (f WeekdayFilter) String() string
- func (f *WeekdayFilter) UnmarshalGQL(v interface{}) error
- func (f *WeekdayFilter) UnmarshalText(data []byte) error
- func (f WeekdayFilter) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClock ¶
AddClock will add the provided number of clock hours to the given time, taking things like DST into account.
func HoursBetween ¶
HoursBetween will return the number of full hours from a to b with respect to clock time and DST.
It is assumed a and b are of the same location.
func NextWeekday ¶
NextWeekday will return t at the start of the next weekday w. The returned value will always be in the future.
func PrevWeekday ¶
PrevWeekday will return t at the start of the most recent weekday w. The returned value will be identical if it is already the start of the requested weekday.
Types ¶
type Clock ¶
Clock represents wall-clock time. It is a duration since midnight.
func ClockDiff ¶
ClockDiff will return the amount of clock time from a to b with respect to DST.
It is assumed a and b are of the same location.
func IsDST ¶
IsDST will return true if there is a DST change within 24-hours AFTER t.
If so, the clock-time and amount of change is calculated.
func NewClockFromTime ¶
NewClockFromTime will return the Clock value of the provided time.
func ParseClock ¶
ParseClock will return a new Clock value given a value in the format of '15:04' or '15:04:05'. The resulting value will be truncated to the minute.
func (Clock) FirstOfDay ¶
FirstOfDay will return the first timestamp where the time matches the clock value, or the first instant after, if it does not exist.
func (Clock) Format ¶
Format will format the clock value using the same format string used by time.Time.
func (Clock) LastOfDay ¶
LastOfDay will return the last timestamp where the time matches the clock value, or the first instant after, if it does not exist.
func (Clock) MarshalGQL ¶ added in v0.28.0
func (Clock) MarshalText ¶ added in v0.28.0
func (*Clock) UnmarshalGQL ¶ added in v0.28.0
func (*Clock) UnmarshalText ¶ added in v0.28.0
type ISODuration ¶ added in v0.30.0
type ISODuration struct { YearPart int MonthPart int WeekPart int DayPart int HourPart int MinutePart int SecondPart float64 }
ISODuration represents an ISO duration string. It is a subset of the ISO 8601 Durations format (https://en.wikipedia.org/wiki/ISO_8601#Durations).
Notably, it does not support negative values, and fractional values are only supported for seconds.
func ISODurationFromTime ¶ added in v0.32.0
func ISODurationFromTime(t time.Duration) ISODuration
ISODurationFromTime returns an ISODuration with the given time.Duration as the time part.
func ParseISODuration ¶ added in v0.30.0
func ParseISODuration(s string) (d ISODuration, err error)
ParseISODuration parses the components of an ISO Duration string. The time components are accurate and are aggregated into one TimePart. The nominal date components cannot be aggregated without accounting for daylight savings time. Supported formats are "PnYnMnDTnHnMnS" and "PnW". Negative values are not supported. Fractional values are only supported for seconds.
func (ISODuration) AddTo ¶ added in v0.30.0
func (dur ISODuration) AddTo(t time.Time) time.Time
AddTo adds the duration to the given time.
func (ISODuration) Days ¶ added in v0.30.0
func (dur ISODuration) Days() int
Days returns the total number of days in the duration (adds DayPart and WeekPart appropriately).
func (ISODuration) Equal ¶ added in v0.30.0
func (dur ISODuration) Equal(t time.Time, other ISODuration) bool
Equal returns true if the duration is equal to the other duration from the given reference time.
func (ISODuration) IsZero ¶ added in v0.30.0
func (dur ISODuration) IsZero() bool
func (ISODuration) LessThan ¶ added in v0.30.0
func (dur ISODuration) LessThan(t time.Time, other ISODuration) bool
LessThan returns true if the duration is less than the other duration from the given reference time.
func (ISODuration) MarshalGQL ¶ added in v0.30.0
func (dur ISODuration) MarshalGQL(w io.Writer)
func (*ISODuration) SetTimePart ¶ added in v0.32.0
func (dur *ISODuration) SetTimePart(timeDur time.Duration)
SetTimePart sets the time portion of the duration from a time.Duration.
func (ISODuration) String ¶ added in v0.30.0
func (dur ISODuration) String() string
String returns an ISO 8601 duration string, rounded to the nearest microsecond.
func (ISODuration) TimePart ¶ added in v0.30.0
func (dur ISODuration) TimePart() time.Duration
TimePart returns the time portion of the duration as a time.Duration.
func (*ISODuration) UnmarshalGQL ¶ added in v0.30.0
func (dur *ISODuration) UnmarshalGQL(v interface{}) error
type ISORInterval ¶ added in v0.30.0
type ISORInterval struct { Repeat int Start time.Time Period ISODuration }
ISORInterval represents an ISO recurring interval.
func ParseISORInterval ¶ added in v0.30.0
func ParseISORInterval(s string) (ISORInterval, error)
ParseISORInterval parses an ISO recurring interval string. If the string has a duration only, the start time will be set to the current time. Infinite intervals are not supported.
func ParseISORIntervalFrom ¶ added in v0.30.0
func ParseISORIntervalFrom(t time.Time, s string) (ISORInterval, error)
ParseISORIntervalFrom parses an ISO recurring interval string. If the string has a duration only, the start time will be set to t. Infinite intervals are not supported.
func (ISORInterval) End ¶ added in v0.30.0
func (r ISORInterval) End() time.Time
End returns the end time of the interval.
func (ISORInterval) MarshalGQL ¶ added in v0.30.0
func (r ISORInterval) MarshalGQL(w io.Writer)
func (ISORInterval) String ¶ added in v0.30.0
func (r ISORInterval) String() string
String returns the string representation of the interval.
func (*ISORInterval) UnmarshalGQL ¶ added in v0.30.0
func (r *ISORInterval) UnmarshalGQL(v interface{}) error
type WeekdayFilter ¶ added in v0.28.0
type WeekdayFilter [7]byte
func EveryDay ¶ added in v0.28.0
func EveryDay() WeekdayFilter
EveryDay returns a WeekdayFilter that is permanently active.
func (WeekdayFilter) Day ¶ added in v0.28.0
func (f WeekdayFilter) Day(d time.Weekday) bool
Day will return true if the given weekday is enabled.
func (WeekdayFilter) DaysSince ¶ added in v0.28.0
func (f WeekdayFilter) DaysSince(d time.Weekday, enabled bool) int
DaysSince will give the number of days since an enabled day from the given weekday. -1 is returned if all days are disabled.
func (WeekdayFilter) DaysUntil ¶ added in v0.28.0
func (f WeekdayFilter) DaysUntil(d time.Weekday, enabled bool) int
DaysUntil will give the number of days until a matching day from the given weekday. -1 is returned if no days match.
func (WeekdayFilter) IsAlways ¶ added in v0.28.0
func (f WeekdayFilter) IsAlways() bool
func (WeekdayFilter) IsNever ¶ added in v0.28.0
func (f WeekdayFilter) IsNever() bool
func (WeekdayFilter) MarshalGQL ¶ added in v0.28.0
func (f WeekdayFilter) MarshalGQL(w io.Writer)
func (WeekdayFilter) MarshalText ¶ added in v0.28.0
func (f WeekdayFilter) MarshalText() ([]byte, error)
func (WeekdayFilter) NextActive ¶ added in v0.28.0
func (f WeekdayFilter) NextActive(t time.Time) time.Time
NextActive returns the next time, at midnight, from t that is active.
If the filter is active every day or no days, zero time is returned. Otherwise the returned value will always be in the future.
func (WeekdayFilter) NextInactive ¶ added in v0.28.0
func (f WeekdayFilter) NextInactive(t time.Time) time.Time
NextInactive returns the next time, at midnight, from t that is no longer active.
If the filter is active every day or no days, zero time is returned. Otherwise the returned value will always be in the future.
func (*WeekdayFilter) Scan ¶ added in v0.28.0
func (f *WeekdayFilter) Scan(src interface{}) error
Scan scans the WeekdayFilter from a DB array of bool.
func (*WeekdayFilter) SetDay ¶ added in v0.28.0
func (f *WeekdayFilter) SetDay(d time.Weekday, enabled bool)
SetDay will update the filter for the given weekday.
func (WeekdayFilter) StartTime ¶ added in v0.28.0
func (f WeekdayFilter) StartTime(t time.Time) time.Time
StartTime returns midnight of the day the filter became active, from the perspective of t.
If the filter is active every day or no days, zero time is returned. If the current day is not active, zero time is returned.
func (WeekdayFilter) String ¶ added in v0.28.0
func (f WeekdayFilter) String() string
String returns a string representation of the WeekdayFilter.
func (*WeekdayFilter) UnmarshalGQL ¶ added in v0.28.0
func (f *WeekdayFilter) UnmarshalGQL(v interface{}) error
func (*WeekdayFilter) UnmarshalText ¶ added in v0.28.0
func (f *WeekdayFilter) UnmarshalText(data []byte) error