Documentation
¶
Index ¶
- Variables
- type Date
- func (d Date) AddDays(days int) Date
- func (d Date) AddMonths(months int) Date
- func (d Date) AddYears(years int) Date
- func (d Date) After(other Date) bool
- func (d Date) Before(other Date) bool
- func (d Date) BeginOfDay() Date
- func (d Date) BeginOfMonth() Date
- func (d Date) BeginOfQuarter() Date
- func (d Date) BeginOfWeek() Date
- func (d Date) BeginOfYear() Date
- func (d Date) Between(start, end Date) bool
- func (d Date) Day() int
- func (d Date) EndOfDay() Date
- func (d Date) EndOfMonth() Date
- func (d Date) EndOfQuarter() Date
- func (d Date) EndOfWeek() Date
- func (d Date) EndOfYear() Date
- func (d Date) Equal(other Date) bool
- func (d Date) Format(layout string) string
- func (d Date) Friday() Date
- func (d Date) IsZero() bool
- func (d Date) Location() *time.Location
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) Monday() Date
- func (d Date) Month() time.Month
- func (d Date) Saturday() Date
- func (d *Date) Scan(src any) error
- func (d Date) String() string
- func (d Date) Sunday() Date
- func (d Date) Thursday() Date
- func (d Date) Tuesday() Date
- func (d Date) Unix() int64
- func (d *Date) UnmarshalJSON(bs []byte) error
- func (d *Date) UnmarshalText(text []byte) error
- func (d Date) Unwrap() time.Time
- func (d Date) Value() (driver.Value, error)
- func (d Date) Wednesday() Date
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- func (d Date) YearDay() int
- type DateTime
- func (dt DateTime) Add(d time.Duration) DateTime
- func (dt DateTime) AddDate(years, months, days int) DateTime
- func (dt DateTime) AddDays(days int) DateTime
- func (dt DateTime) AddHours(hours int) DateTime
- func (dt DateTime) AddMinutes(minutes int) DateTime
- func (dt DateTime) AddMonths(months int) DateTime
- func (dt DateTime) AddSeconds(seconds int) DateTime
- func (dt DateTime) AddYears(years int) DateTime
- func (dt DateTime) After(other DateTime) bool
- func (dt DateTime) Before(other DateTime) bool
- func (dt DateTime) BeginOfDay() DateTime
- func (dt DateTime) BeginOfHour() DateTime
- func (dt DateTime) BeginOfMinute() DateTime
- func (dt DateTime) BeginOfMonth() DateTime
- func (dt DateTime) BeginOfQuarter() DateTime
- func (dt DateTime) BeginOfWeek() DateTime
- func (dt DateTime) BeginOfYear() DateTime
- func (dt DateTime) Between(start, end DateTime) bool
- func (dt DateTime) Day() int
- func (dt DateTime) EndOfDay() DateTime
- func (dt DateTime) EndOfHour() DateTime
- func (dt DateTime) EndOfMinute() DateTime
- func (dt DateTime) EndOfMonth() DateTime
- func (dt DateTime) EndOfQuarter() DateTime
- func (dt DateTime) EndOfWeek() DateTime
- func (dt DateTime) EndOfYear() DateTime
- func (dt DateTime) Equal(other DateTime) bool
- func (dt DateTime) Format(layout string) string
- func (dt DateTime) Friday() DateTime
- func (dt DateTime) Hour() int
- func (dt DateTime) IsZero() bool
- func (dt DateTime) Location() *time.Location
- func (dt DateTime) MarshalJSON() ([]byte, error)
- func (dt DateTime) MarshalText() ([]byte, error)
- func (dt DateTime) Minute() int
- func (dt DateTime) Monday() DateTime
- func (dt DateTime) Month() time.Month
- func (dt DateTime) Nanosecond() int
- func (dt DateTime) Saturday() DateTime
- func (dt *DateTime) Scan(src any) error
- func (dt DateTime) Second() int
- func (dt DateTime) String() string
- func (dt DateTime) Sunday() DateTime
- func (dt DateTime) Thursday() DateTime
- func (dt DateTime) Tuesday() DateTime
- func (dt DateTime) Unix() int64
- func (dt DateTime) UnixMicro() int64
- func (dt DateTime) UnixMilli() int64
- func (dt DateTime) UnixNano() int64
- func (dt *DateTime) UnmarshalJSON(bs []byte) error
- func (dt *DateTime) UnmarshalText(text []byte) error
- func (dt DateTime) Unwrap() time.Time
- func (dt DateTime) Value() (driver.Value, error)
- func (dt DateTime) Wednesday() DateTime
- func (dt DateTime) Weekday() time.Weekday
- func (dt DateTime) Year() int
- func (dt DateTime) YearDay() int
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) AddHours(hours int) Time
- func (t Time) AddMicroseconds(microseconds int64) Time
- func (t Time) AddMilliseconds(milliseconds int64) Time
- func (t Time) AddMinutes(minutes int) Time
- func (t Time) AddNanoseconds(nanoseconds int64) Time
- func (t Time) AddSeconds(seconds int) Time
- func (t Time) After(other Time) bool
- func (t Time) Before(other Time) bool
- func (t Time) BeginOfHour() Time
- func (t Time) BeginOfMinute() Time
- func (t Time) Between(start, end Time) bool
- func (t Time) EndOfHour() Time
- func (t Time) EndOfMinute() Time
- func (t Time) Equal(other Time) bool
- func (t Time) Format(layout string) string
- func (t Time) Hour() int
- func (t Time) IsZero() bool
- 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) Scan(src any) error
- func (t Time) Second() int
- func (t Time) String() string
- func (t *Time) UnmarshalJSON(bs []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t Time) Unwrap() time.Time
- func (t Time) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidDateFormat indicates date format is invalid. ErrInvalidDateFormat = errors.New("invalid date format") // ErrInvalidDateTimeFormat indicates datetime format is invalid. ErrInvalidDateTimeFormat = errors.New("invalid datetime format") // ErrInvalidTimeFormat indicates time format is invalid. ErrInvalidTimeFormat = errors.New("invalid time format") // ErrFailedScan indicates scan target type/value is invalid. ErrFailedScan = errors.New("failed to scan value") // ErrUnsupportedDestType indicates dest type is unsupported. ErrUnsupportedDestType = errors.New("unsupported destination type") // ErrInvalidJSONFormat indicates invalid JSON length/quotes for datetime types. ErrInvalidJSONFormat = errors.New("invalid JSON format: expected quoted value of specific length") )
Functions ¶
This section is empty.
Types ¶
type Date ¶
Date represents a date value (without time) with database and JSON support. It uses the standard time.DateOnly format (2006-01-02).
func ParseDate ¶
ParseDate parses a date string and returns a Date. First tries with the provided pattern, then falls back to cast.ToTime as a backup.
func (Date) BeginOfDay ¶
BeginOfDay returns the beginning of the day for d (same as the date itself).
func (Date) BeginOfMonth ¶
BeginOfMonth returns the beginning of the month for d.
func (Date) BeginOfQuarter ¶
BeginOfQuarter returns the beginning of the quarter for d.
func (Date) BeginOfWeek ¶
BeginOfWeek returns the beginning of the week (Sunday) for d.
func (Date) BeginOfYear ¶
BeginOfYear returns the beginning of the year for d.
func (Date) EndOfMonth ¶
EndOfMonth returns the end of the month for d.
func (Date) EndOfQuarter ¶
EndOfQuarter returns the end of the quarter for d.
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for JSON serialization.
func (Date) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (Date) Unix ¶
Unix returns d as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for JSON deserialization.
func (*Date) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type DateTime ¶
DateTime represents a date and time value with database and JSON support. It uses the standard time.DateTime format (2006-01-02 15:04:05).
func FromUnix ¶
FromUnix returns the DateTime corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC.
func FromUnixMicro ¶
FromUnixMicro returns the DateTime corresponding to the given Unix time, usec microseconds since January 1, 1970 UTC.
func FromUnixMilli ¶
FromUnixMilli returns the DateTime corresponding to the given Unix time, msec milliseconds since January 1, 1970 UTC.
func Parse ¶
Parse parses a date time string and returns a DateTime. First tries with the provided pattern, then falls back to cast.ToTime as a backup.
func (DateTime) AddDate ¶
AddDate returns the datetime corresponding to adding the given number of years, months, and days to dt.
func (DateTime) AddMinutes ¶
AddMinutes adds the specified number of minutes to the datetime.
func (DateTime) AddSeconds ¶
AddSeconds adds the specified number of seconds to the datetime.
func (DateTime) BeginOfDay ¶
BeginOfDay returns the beginning of the day for dt.
func (DateTime) BeginOfHour ¶
BeginOfHour returns the beginning of the hour for dt.
func (DateTime) BeginOfMinute ¶
BeginOfMinute returns the beginning of the minute for dt.
func (DateTime) BeginOfMonth ¶
BeginOfMonth returns the beginning of the month for dt.
func (DateTime) BeginOfQuarter ¶
BeginOfQuarter returns the beginning of the quarter for dt.
func (DateTime) BeginOfWeek ¶
BeginOfWeek returns the beginning of the week (Sunday) for dt.
func (DateTime) BeginOfYear ¶
BeginOfYear returns the beginning of the year for dt.
func (DateTime) EndOfMinute ¶
EndOfMinute returns the end of the minute for dt.
func (DateTime) EndOfMonth ¶
EndOfMonth returns the end of the month for dt.
func (DateTime) EndOfQuarter ¶
EndOfQuarter returns the end of the quarter for dt.
func (DateTime) IsZero ¶
IsZero reports whether dt represents the zero time instant, January 1, year 1, 00:00:00 UTC.
func (DateTime) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for JSON serialization.
func (DateTime) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (DateTime) Minute ¶
Minute returns the minute offset within the hour specified by dt, in the range [0, 59].
func (DateTime) Nanosecond ¶
Nanosecond returns the nanosecond offset within the second specified by dt, in the range [0, 999999999].
func (DateTime) Second ¶
Second returns the second offset within the minute specified by dt, in the range [0, 59].
func (DateTime) String ¶
String returns the string representation using the standard DateTime layout.
func (DateTime) Unix ¶
Unix returns dt as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
func (DateTime) UnixMicro ¶
UnixMicro returns dt as a Unix time, the number of microseconds elapsed since January 1, 1970 UTC.
func (DateTime) UnixMilli ¶
UnixMilli returns dt as a Unix time, the number of milliseconds elapsed since January 1, 1970 UTC.
func (DateTime) UnixNano ¶
UnixNano returns dt as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for JSON deserialization.
func (*DateTime) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Time ¶
Time represents a time value (without date) with database and JSON support. It uses the standard time.TimeOnly format (15:04:05).
func ParseTime ¶
ParseTime parses a time string and returns a Time. First tries with the provided pattern, then falls back to cast.ToTime as a backup.
func (Time) AddMicroseconds ¶
AddMicroseconds adds the specified number of microseconds to the time.
func (Time) AddMilliseconds ¶
AddMilliseconds adds the specified number of milliseconds to the time.
func (Time) AddMinutes ¶
AddMinutes adds the specified number of minutes to the time.
func (Time) AddNanoseconds ¶
AddNanoseconds adds the specified number of nanoseconds to the time.
func (Time) AddSeconds ¶
AddSeconds adds the specified number of seconds to the time.
func (Time) BeginOfHour ¶
BeginOfHour returns the beginning of the hour for t.
func (Time) BeginOfMinute ¶
BeginOfMinute returns the beginning of the minute for t.
func (Time) EndOfMinute ¶
EndOfMinute returns the end of the minute for t.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for JSON serialization.
func (Time) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (Time) Minute ¶
Minute returns the minute offset within the hour specified by t, in the range [0, 59].
func (Time) Nanosecond ¶
Nanosecond returns the nanosecond offset within the second specified by t, in the range [0, 999999999].
func (Time) Second ¶
Second returns the second offset within the minute specified by t, in the range [0, 59].
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for JSON deserialization.
func (*Time) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.