Documentation ¶
Index ¶
- Variables
- func EndOfWeek(startOfWeek time.Weekday) time.Weekday
- func LocalWeekday(startOfWeek, day time.Weekday) int
- type ExclusiveInterval
- type InclusiveInterval
- type Interval
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) AddDate(years, months, days int) Time
- func (t Time) After(u Time) bool
- func (t Time) Before(u Time) bool
- func (t Time) Between(start, end Time) bool
- func (t Time) Compare(u Time) int
- func (t Time) EndOfDay() Time
- func (t Time) EndOfMonth() Time
- func (t Time) EndOfWeek() Time
- func (t Time) Equal(u Time) bool
- func (t Time) In(loc *time.Location) Time
- func (t Time) Local() Time
- func (t Time) LocalWeekday() int
- func (t Time) MarshalBinary() (data []byte, err error)
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() (text []byte, err error)
- func (t Time) PB() *timestamppb.Timestamp
- func (t Time) Round(d time.Duration) Time
- func (t *Time) RuMonthName() string
- func (t *Time) RuMonthNamePrepositional() string
- func (t *Time) Scan(src any) error
- func (t Time) StartOfDay() Time
- func (t Time) StartOfMonth() Time
- func (t Time) StartOfWeek() Time
- func (t Time) Std() time.Time
- func (t Time) Sub(u Time) time.Duration
- func (t Time) Truncate(d time.Duration) Time
- func (t Time) UTC() Time
- func (t *Time) UnmarshalBinary(data []byte) error
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t Time) Value() (driver.Value, error)
- func (t Time) ZoneBounds() (start, end Time)
Constants ¶
This section is empty.
Variables ¶
var ( // MarshalFormat to use for (un-)marshaling time.Time values. MarshalFormat = time.RFC3339 // SQLFormat to use for (un-)marshaling time.Time values with sql drivers. SQLFormat = time.RFC3339Nano // StartOfWeek is the beginning of the week. // This overrides the default time.Sunday and changes behavior of weekday-related functions in this package. StartOfWeek = time.Monday )
Functions ¶
func EndOfWeek ¶
EndOfWeek returns the circular-shifted time.Weekday according to the defined StartOfWeek global variable.
func LocalWeekday ¶
LocalWeekday returns the circular-shifted weekday number [0; 6] according to the given `startOfWeek`.
Types ¶
type ExclusiveInterval ¶ added in v2.27.0
type ExclusiveInterval Interval
ExclusiveInterval is the right-open Interval [StartTime, EndTime). Mimics the interval.Interval proto representation.
func IntervalFromPB ¶ added in v2.26.0
func IntervalFromPB(pb *interval.Interval) ExclusiveInterval
IntervalFromPB creates an ExclusiveInterval from the given proto representation.
func (ExclusiveInterval) Contains ¶ added in v2.27.0
func (i ExclusiveInterval) Contains(t Time) bool
Contains returns `true` if the given Time t is contained in the ExclusiveInterval.
func (ExclusiveInterval) Inclusive ¶ added in v2.27.0
func (i ExclusiveInterval) Inclusive() InclusiveInterval
Inclusive is an equivalent conversion of the ExclusiveInterval to the InclusiveInterval. Conversion precision is time.Nanosecond.
func (ExclusiveInterval) IsValid ¶ added in v2.27.0
func (i ExclusiveInterval) IsValid() bool
IsValid checks if the ExclusiveInterval does not overlap itself.
func (ExclusiveInterval) IsZero ¶ added in v2.27.0
func (i ExclusiveInterval) IsZero() bool
IsZero is a wrapper for Interval.IsZero().
func (ExclusiveInterval) PB ¶ added in v2.27.0
func (i ExclusiveInterval) PB() *interval.Interval
PB converts the ExclusiveInterval to the proto representation.
type InclusiveInterval ¶ added in v2.27.0
type InclusiveInterval Interval
InclusiveInterval is the closed Interval [StartTime, EndTime].
func (InclusiveInterval) Contains ¶ added in v2.27.0
func (i InclusiveInterval) Contains(t Time) bool
Contains returns `true` if the given Time t is contained in the InclusiveInterval.
func (InclusiveInterval) Exclusive ¶ added in v2.27.0
func (i InclusiveInterval) Exclusive() ExclusiveInterval
Exclusive is an equivalent conversion of the InclusiveInterval to the ExclusiveInterval. Conversion precision is time.Nanosecond.
func (InclusiveInterval) IsValid ¶ added in v2.27.0
func (i InclusiveInterval) IsValid() bool
IsValid checks if the InclusiveInterval does not overlap itself.
func (InclusiveInterval) IsZero ¶ added in v2.27.0
func (i InclusiveInterval) IsZero() bool
IsZero is a wrapper for Interval.IsZero().
func (InclusiveInterval) PB ¶ added in v2.27.0
func (i InclusiveInterval) PB() *interval.Interval
PB converts the InclusiveInterval to the proto representation.
type Interval ¶ added in v2.26.0
Interval is a common time interval. Should not be used directly, see InclusiveInterval and ExclusiveInterval instead.
type Time ¶
Time is a wrapper around time.Time with some useful methods.
func FromPB ¶
func FromPB(t *timestamppb.Timestamp) Time
FromPB creates a Time from a protobuf timestamp.
func (Time) EndOfWeek ¶
EndOfWeek returns the end of the week according to the defined StartOfWeek global variable.
func (Time) LocalWeekday ¶
LocalWeekday returns the circular-shifted weekday number [0; 6] according to the defined StartOfWeek global variable.
func (Time) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for the defined MarshalFormat global variable.
func (Time) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for the defined MarshalFormat global variable.
func (Time) PB ¶
func (t Time) PB() *timestamppb.Timestamp
PB converts a Time to a protobuf timestamp.
func (*Time) RuMonthName ¶
RuMonthName returns the name of month in Russian.
func (*Time) RuMonthNamePrepositional ¶
RuMonthNamePrepositional returns the name of month in Russian in prepositional case.
func (*Time) Scan ¶
Scan implements the sql.Scanner interface for the defined SQLFormat global variable. Scans the local time.
func (Time) StartOfMonth ¶
StartOfMonth returns the start of the month.
func (Time) StartOfWeek ¶
StartOfWeek returns the start of the week according to the defined StartOfWeek global variable.
func (*Time) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. Returns the local time.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for the defined MarshalFormat global variable. Returns the local time.
func (*Time) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for the defined MarshalFormat global variable. Returns the local time.
func (Time) Value ¶
Value implements the driver.Valuer interface for the defined SQLFormat global variable.
func (Time) ZoneBounds ¶
ZoneBounds wraps the standard function.