Documentation
¶
Index ¶
- Constants
- type Date
- func DateFromLayout(layout, str string) (Date, error)
- func DateFromNow() Date
- func DateFromStdTime(t time.Time) Date
- func DateFromString(str string) (Date, error)
- func DateFromUnix(sec int64, nsec int64) Date
- func DateFromUnixMicro(usec int64) Date
- func DateFromUnixMilli(msec int64) Date
- func NewDate(year int, month time.Month, day int) Date
- func (d Date) AddDate(years int, months int, days int) Date
- func (d Date) After(rhs Date) bool
- func (d Date) AfterOrEqual(rhs Date) bool
- func (d Date) AppendFormat(b []byte, layout string) []byte
- func (d Date) Before(rhs Date) bool
- func (d Date) BeforeOrEqual(rhs Date) bool
- func (d Date) Between(start, end Date) bool
- func (d Date) BetweenOrEqual(start, end Date) bool
- func (d Date) Date() (year int, month time.Month, day int)
- func (d Date) Day() int
- func (d Date) Equal(rhs Date) bool
- func (d Date) Format(layout string) string
- func (d Date) GoString() string
- func (d Date) ISOWeek() (year, week int)
- 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() time.Month
- func (d *Date) Scan(value any) error
- func (d Date) String() string
- func (d Date) ToStdTime() time.Time
- func (d Date) Unix() int64
- func (d Date) UnixMicro() int64
- func (d Date) UnixMilli() int64
- func (d Date) UnixNano() int64
- func (d *Date) UnmarshalBinary(data []byte) error
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d *Date) UnmarshalText(data []byte) error
- func (d Date) Value() (driver.Value, error)
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- func (d Date) YearDay() int
- type DateTime
- func DateTimeFromLayout(layout, str string) (DateTime, error)
- func DateTimeFromLayoutLocation(layout, str string, loc *time.Location) (DateTime, error)
- func DateTimeFromNow() DateTime
- func DateTimeFromStdTime(t time.Time) DateTime
- func DateTimeFromString(str string) (DateTime, error)
- func DateTimeFromStringLocation(str string, loc *time.Location) (DateTime, error)
- func DateTimeFromUnix(sec int64, nsec int64) DateTime
- func DateTimeFromUnixMicro(usec int64) DateTime
- func DateTimeFromUnixMilli(msec int64) DateTime
- func NewDateTime(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) DateTime
- func (d DateTime) Add(dur time.Duration) DateTime
- func (d DateTime) AddDate(years int, months int, days int) DateTime
- func (d DateTime) After(rhs DateTime) bool
- func (d DateTime) AfterOrEqual(rhs DateTime) bool
- func (d DateTime) AppendFormat(b []byte, layout string) []byte
- func (d DateTime) Before(rhs DateTime) bool
- func (d DateTime) BeforeOrEqual(rhs DateTime) bool
- func (d DateTime) Between(start, end DateTime) bool
- func (d DateTime) BetweenOrEqual(start, end DateTime) bool
- func (d DateTime) Clock() (hour, min, sec int)
- func (d DateTime) Date() (year int, month time.Month, day int)
- func (d DateTime) Day() int
- func (d DateTime) Equal(rhs DateTime) bool
- func (d DateTime) Format(layout string) string
- func (d DateTime) GoString() string
- func (d *DateTime) GobDecode(data []byte) error
- func (d DateTime) GobEncode() ([]byte, error)
- func (d DateTime) Hour() int
- func (d DateTime) ISOWeek() (year, week int)
- func (d DateTime) In(loc *time.Location) DateTime
- func (d DateTime) IsDST() bool
- func (d DateTime) IsZero() bool
- func (d DateTime) Local() DateTime
- func (d DateTime) Location() *time.Location
- 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() time.Month
- func (d DateTime) Nanosecond() int
- func (d DateTime) Round(dur time.Duration) DateTime
- func (d *DateTime) Scan(value any) error
- func (d DateTime) Second() int
- func (d DateTime) String() string
- func (d DateTime) Sub(u DateTime) time.Duration
- func (d DateTime) ToDate() Date
- func (d DateTime) ToStdTime() time.Time
- func (d DateTime) ToTime() Time
- func (d DateTime) Truncate(dur time.Duration) DateTime
- func (d DateTime) UTC() DateTime
- func (d DateTime) Unix() int64
- func (d DateTime) UnixMicro() int64
- func (d DateTime) UnixMilli() int64
- func (d DateTime) UnixNano() int64
- func (d *DateTime) UnmarshalBinary(data []byte) error
- func (d *DateTime) UnmarshalJSON(data []byte) error
- func (d *DateTime) UnmarshalText(data []byte) error
- func (d DateTime) Value() (driver.Value, error)
- func (d DateTime) Weekday() time.Weekday
- func (d DateTime) Year() int
- func (d DateTime) YearDay() int
- func (d DateTime) Zone() (name string, offset int)
- type Time
- func NewTime(hour, min, sec, nsec int, loc *time.Location) Time
- func TimeFromLayout(layout, str string) (Time, error)
- func TimeFromLayoutLocation(layout, str string, loc *time.Location) (Time, error)
- func TimeFromNow() Time
- func TimeFromStdTime(t time.Time) Time
- func TimeFromString(str string) (Time, error)
- func TimeFromStringLocation(str string, loc *time.Location) (Time, error)
- func TimeFromUnix(sec int64, nsec int64) Time
- func TimeFromUnixMicro(usec int64) Time
- func TimeFromUnixMilli(msec int64) Time
- func (t Time) Add(dur time.Duration) Time
- func (t Time) After(rhs Time) bool
- func (t Time) AfterOrEqual(rhs Time) bool
- func (t Time) AppendFormat(b []byte, layout string) []byte
- func (t Time) Before(rhs Time) bool
- func (t Time) BeforeOrEqual(rhs Time) bool
- func (t Time) Between(start, end Time) bool
- func (t Time) BetweenOrEqual(start, end Time) bool
- func (t Time) Clock() (hour, min, sec int)
- func (t Time) Equal(rhs Time) bool
- func (t Time) Format(layout string) string
- func (t Time) GoString() string
- func (t Time) Hour() int
- func (t Time) In(loc *time.Location) Time
- func (t Time) IsDST() bool
- func (t Time) IsZero() bool
- func (t Time) Local() Time
- func (t Time) Location() *time.Location
- func (t Time) MarshalBinary() ([]byte, error)
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t Time) Minute() int
- func (t Time) Nanosecond() int
- func (t Time) Round(dur time.Duration) Time
- func (t *Time) Scan(value any) error
- func (t Time) Second() int
- func (t Time) String() string
- func (t Time) Sub(u Time) time.Duration
- func (t Time) ToStdTime() time.Time
- func (t Time) Truncate(dur time.Duration) Time
- func (t Time) UTC() Time
- func (d *Time) UnmarshalBinary(data []byte) error
- func (d *Time) UnmarshalJSON(data []byte) error
- func (d *Time) UnmarshalText(data []byte) error
- func (t Time) Value() (driver.Value, error)
- func (t Time) Zone() (name string, offset int)
Constants ¶
const ( // DateTimeSQLLayout is exported so you can change this for your project // but the default should be sufficient. It used microsecond precision // to align with postgresq/mysql. DateTimeSQLLayout = "2006-01-02 15:04:05.999999-07" )
const ( // TimeSQLLayout is exported so you can change this for your project // but the default should be sufficient. It used microsecond precision // to align with postgresq/mysql. TimeSQLLayout = "15:04:05.999999-07" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date type, based on time.Time.
func DateFromLayout ¶
DateFromLayout parses a Date from layout
func DateFromNow ¶
func DateFromNow() Date
DateFromNow returns a new date using the current date. It uses time.Now() as a reference date, discarding time information.
func DateFromStdTime ¶
FromTime converts from the stdlib time.Time type, discarding time information
func DateFromString ¶
DateFromString parses a Date from RFC3339 full-date
func DateFromUnix ¶
DateFromUnix converts a unix timestamp in seconds into a date.
func DateFromUnixMicro ¶
DateFromUnixMicro converts a unix timestamp in microseconds into a date.
func DateFromUnixMilli ¶
DateFromUnixMilli converts a unix timestamp in milliseconds into a date.
func (Date) AfterOrEqual ¶
AfterOrEqual returns true if d is equal to or after rhs
func (Date) AppendFormat ¶
AppendFormat is like Format but appends the textual representation to b and returns the extended buffer. Due to this package using time.Time the layout string is not checked for time-like parts that could be leaked out but will be zero.
func (Date) BeforeOrEqual ¶
BeforeOrEqual returns true if d is equal to or before rhs
func (Date) BetweenOrEqual ¶
BetweenOrEqual returns true if d is in the inclusive time range [start, end]
func (Date) Format ¶
Format using a layout string from time.Time. This can accidentally pull zero'd time information from the underlying time.Time so caution must be used.
func (Date) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface. Is always a width of 32 bits (4 bytes).
func (Date) MarshalJSON ¶
MarshalJSON implements json.Marshaller
func (Date) MarshalText ¶
MarshalText implements encoding.TextMarshaller
func (Date) ToStdTime ¶
ToStdTime returns a time.Time with the time component zero'd out in UTC location.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON parses a quoted ISO8601 date / RFC3339 full-date
func (*Date) UnmarshalText ¶
UnmarshalText parses a byte string with ISO8601 date / RFC3339 full-date
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime is mostly a pass-through wrapper for time.Time. This allows nicer interoperability with the Time and Date types as well as a couple additional utility methods.
func DateTimeFromLayout ¶
DateTimeFromString parses a date time by layout in the local location.
func DateTimeFromLayoutLocation ¶
DateTimeFromStringLocation parses a date time by layout in the specified location.
func DateTimeFromNow ¶
func DateTimeFromNow() DateTime
DateTimeFromNow creates a new date time from the current moment in time (local).
func DateTimeFromStdTime ¶
DateTimeFromStdTime converts a time.Time into a datetime
func DateTimeFromString ¶
DateTimeFromString parses a date time (ISO8601/RFC3339 date-time) in the local location.
func DateTimeFromStringLocation ¶
DateTimeFromStringLocation parses a date time (ISO8601/RFC3339 date-time) in the specified location.
func DateTimeFromUnix ¶
Unix returns the local Time corresponding to the given Unix time
func DateTimeFromUnixMicro ¶
UnixMicro returns the local Time corresponding to the given Unix time in microseconds
func DateTimeFromUnixMilli ¶
UnixMicro returns the local Time corresponding to the given Unix time in milliseconds
func NewDateTime ¶
func NewDateTime(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) DateTime
NewDateTime from all components
func (DateTime) AfterOrEqual ¶
AfterOrEqual returns true if rhs is equal to or after d
func (DateTime) AppendFormat ¶
AppendFormat passes through to the underlying time.Time but.
func (DateTime) BeforeOrEqual ¶
BeforeOrEqual returns true if rhs is before d
func (DateTime) BetweenOrEqual ¶
BetweenOrEqual returns true if d is in the inclusive time range [start, end]
func (DateTime) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (DateTime) MarshalJSON ¶
MarshalJSON implements json.Marshaller
func (DateTime) MarshalText ¶
MarshalText implements encoding.TextMarshaller
func (DateTime) Nanosecond ¶
Nanosecond returns the nanosecond offset
func (DateTime) ToDate ¶
ToDate discards the time component of this datetime to convert it into a date.
The timezone is discarded along with the time, so the date will be whatever it was in the timezone, it is not converted to UTC or anything before the conversion.
func (DateTime) ToTime ¶
ToTime discards the date component of this datetime to convert it into a time.
func (*DateTime) UnmarshalBinary ¶
UnmarshalBinary
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON parses a quoted ISO8601 DateTime / RFC3339 full-DateTime
func (*DateTime) UnmarshalText ¶
UnmarshalText parses a byte string with ISO8601 DateTime / RFC3339 full-DateTime
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time is mostly a pass-through wrapper for time.Time. This allows nicer interoperability with the Time and Date types as well as a couple additional utility methods.
func TimeFromLayout ¶
TimeFromString parses a time from a layout in the local location.
func TimeFromLayoutLocation ¶
TimeFromStringLocation parses a time from a layout in the specified location.
func TimeFromNow ¶
func TimeFromNow() Time
TimeFromNow creates a new date time from the current moment in time (local).
func TimeFromStdTime ¶
TimeFromStdTime creates a time object discarding the stdlib time.Time's date information.
func TimeFromString ¶
TimeFromString parses a date time (ISO8601/RFC3339 date-time) in the local location.
func TimeFromStringLocation ¶
TimeFromStringLocation parses a date time (ISO8601/RFC3339 date-time) in the specified location.
func TimeFromUnix ¶
Unix returns the local Time corresponding to the given Unix time, discards the date information.
func TimeFromUnixMicro ¶
UnixMicro returns the local Time corresponding to the given Unix time in microseconds. Discards the date information.
func TimeFromUnixMilli ¶
UnixMicro returns the local Time corresponding to the given Unix time in milliseconds. Discards the date information.
func (Time) AfterOrEqual ¶
AfterOrEqual returns true if rhs is equal to or after d
func (Time) AppendFormat ¶
AppendFormat is like Format but appends the textual representation to b and returns the extended buffer. Due to this package using time.Time the layout string is not checked for date-like parts that could be leaked out but will be zero.
func (Time) BeforeOrEqual ¶
BeforeOrEqual returns true if rhs is before d
func (Time) BetweenOrEqual ¶
BetweenOrEqual returns true if t is in the inclusive time range [start, end]
func (Time) Format ¶
Format using a layout string from time.Time. This can accidentally pull zero'd date information from the underlying time.Time so caution must be used.
func (Time) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface. This is inefficient because it actually will use time.Time's entire MarshalBinary method which means that it will be much larger due to date information also being stored.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaller
func (Time) MarshalText ¶
MarshalText implements encoding.TextMarshaller
func (*Time) UnmarshalJSON ¶
UnmarshalJSON parses a quoted ISO8601 Time / RFC3339 full-time
func (*Time) UnmarshalText ¶
UnmarshalText parses a byte string with ISO8601 Time / RFC3339 full-time