Documentation
¶
Index ¶
- Constants
- type Date
- func DateFromOrdinalDate(year, dayOfYear int) (Date, error)
- func DateFromTime(t time.Time) Date
- func MustDateFromOrdinalDate(year, dayOfYear int) Date
- func MustNewDate(year, month, day int) Date
- func NewDate(year, month, day int) (Date, error)
- func ParseDate(layout, value string) (Date, error)
- func Today(location *time.Location) Date
- func (d Date) Add(years, months, days int) Date
- func (d Date) AddDays(days int) Date
- func (d Date) After(dd Date) bool
- func (d Date) Before(dd Date) bool
- func (d Date) Date() (year, month, day int)
- func (d Date) Day() int
- func (d Date) DayOfYear() int
- func (d Date) Equal(dd 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) MarshalJSON() ([]byte, error)
- func (d Date) Month() int
- func (d Date) OrdinalDate() (year, dayOfYear int)
- func (d Date) Quarter() int
- func (d *Date) Scan(value interface{}) (err error)
- func (d Date) String() string
- func (d Date) Sub(dd Date) int
- func (d Date) Time(location *time.Location) time.Time
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d Date) Value() (driver.Value, error)
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- type NullDate
- type NullTimeOfDay
- type ParseError
- type StringDate
- type TimeOfDay
- func (t TimeOfDay) Add(hours, mins, secs, nsecs int) (int, TimeOfDay)
- func (t TimeOfDay) AddDuration(d time.Duration) (int, TimeOfDay)
- func (t TimeOfDay) After(tt TimeOfDay) bool
- func (t TimeOfDay) Before(tt TimeOfDay) bool
- func (t TimeOfDay) Clock() (hour, min, sec, nsec int)
- func (t TimeOfDay) Equal(tt TimeOfDay) bool
- func (t TimeOfDay) Format(layout string) string
- func (t TimeOfDay) GoString() string
- func (t TimeOfDay) Hour() int
- func (t TimeOfDay) IsZero() bool
- func (t TimeOfDay) MarshalJSON() ([]byte, error)
- func (t TimeOfDay) Minute() int
- func (t TimeOfDay) Nanosecond() int
- func (t *TimeOfDay) Scan(value interface{}) (err error)
- func (t TimeOfDay) Second() int
- func (t TimeOfDay) String() string
- func (t TimeOfDay) Sub(tt TimeOfDay) time.Duration
- func (t *TimeOfDay) UnmarshalJSON(data []byte) error
- func (t TimeOfDay) Value() (driver.Value, error)
Constants ¶
const ( // Deprecated: Use [RFC3339Date] instead. RFC3339 = RFC3339Date RFC3339Date = "YYYY-MM-DD" )
const (
RFC3339Time = "HH:mm:ss"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date represents a specific day in Gregorian calendar.
The zero value of type Date is January 1 of year 1.
func DateFromOrdinalDate ¶
DateFromOrdinalDate returns the date corresponding to year, day of year.
func DateFromTime ¶
DateFromTime returns the date specified by t.
func MustDateFromOrdinalDate ¶
MustDateFromOrdinalDate is like DateFromOrdinalDate but panics if the date cannot be created.
func MustNewDate ¶
MustNewDate is like NewDate but panics if the date cannot be created.
func ParseDate ¶
ParseDate parses a formatted string and returns the date it represents.
YY 01 Two-digit year YYYY 2001 Four-digit year M 1-12 Month, beginning at 1 MM 01-12 Month, 2-digits MMM Jan-Dec The abbreviated month name MMMM January-December The full month name D 1-31 Day of month DD 01-31 Day of month, 2-digits
func (Date) Add ¶
Add returns the date corresponding to adding the given number of years, months, and days to d.
func (Date) AddDays ¶
AddDays returns the date corresponding to adding the given number of days to d.
func (Date) Format ¶
Format returns a textual representation of the date.
YY 01 Two-digit year YYYY 2001 Four-digit year M 1-12 Month, beginning at 1 MM 01-12 Month, 2-digits MMM Jan-Dec The abbreviated month name MMMM January-December The full month name D 1-31 Day of month DD 01-31 Day of month, 2-digits
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. The date is a quoted string in RFC 3339 format.
func (Date) OrdinalDate ¶
OrdinalDate returns the ordinal date specified by d.
func (Date) Sub ¶
Sub returns the days d-dd. If the result exceeds the integer scope, the maximum (or minimum) integer will be returned.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. The date is expected to be a quoted string in RFC 3339 format.
type NullDate ¶
NullDate represents a specific day in Gregorian calendar that may be null. NullDate implements the sql.Scanner interface, so it can be used as a scan destination, similar to sql.NullString.
type NullTimeOfDay ¶ added in v1.1.0
type NullTimeOfDay struct {
TimeOfDay TimeOfDay
Valid bool // Valid is true if TimeOfDay is not NULL.
}
NullTimeOfDay represents a specific time in a day that may be null. NullTimeOfDay implements the sql.Scanner interface, so it can be used as a scan destination, similar to sql.NullString.
func (*NullTimeOfDay) Scan ¶ added in v1.1.0
func (t *NullTimeOfDay) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type ParseError ¶
ParseError describes a problem parsing a string.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns the string representation of a ParseError.
type StringDate ¶ added in v1.1.0
type StringDate struct {
Date Date
}
StringDate is a wrapper of Date that represents zero date as empty string in JSON.
func (StringDate) MarshalJSON ¶ added in v1.1.0
func (d StringDate) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. The string date is an empty string or a quoted string in RFC 3339 format.
func (*StringDate) UnmarshalJSON ¶ added in v1.1.0
func (d *StringDate) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. The string date is expected to be an empty string or a quoted string in RFC 3339 format.
type TimeOfDay ¶ added in v1.1.0
type TimeOfDay struct {
// contains filtered or unexported fields
}
TimeOfDay represents a specific time in a day.
func MustNewTimeOfDay ¶ added in v1.1.0
MustNewTimeOfDay is like NewTimeOfDay but panics if the time of day cannot be created.
func NewTimeOfDay ¶ added in v1.1.0
NewTimeOfDay returns the time of day corresponding to hour, minute, second, and nanosecond.
func ParseTimeOfDay ¶ added in v1.1.0
ParseTimeOfDay parses a formatted string and returns the time of day it represents.
a am/pm ante meridiem or post meridiem A AM/PM ante meridiem or post meridiem H 0-23 Two-digit hour, 24-hour clock HH 00-23 Hour, 24-hour clock h 1-12 Two-digit hour, 12-hour clock hh 01-12 Hour, 12-hour clock m 0-59 Minute mm 00-59 Minute, 2-digits s 0-59 Second, including fraction ss 00-59 Second, 2-digits, including fraction
func TimeOfDayFromTime ¶ added in v1.1.0
TimeOfDayFromTime returns the time of day specified by t.
func TimeOfDayNow ¶ added in v1.1.0
TimeOfDayNow returns the current time of day in the given location.
func (TimeOfDay) Add ¶ added in v1.1.0
Add returns the exceeded days and the time of day corresponding to adding the given number of hours, minutes, seconds and nanoseconds to t.
func (TimeOfDay) AddDuration ¶ added in v1.1.0
AddDuration returns the exceeded days and the time of day corresponding to adding the given time.Duration to t.
func (TimeOfDay) Clock ¶ added in v1.1.0
Clock returns the hour, minute, second and nanosecond specified by t.
func (TimeOfDay) Equal ¶ added in v1.1.0
Equal reports whether the time of day t and tt is the same time.
func (TimeOfDay) Format ¶ added in v1.1.0
Format returns a textual representation of the time of day.
a am/pm ante meridiem or post meridiem A AM/PM ante meridiem or post meridiem H 0-23 Two-digit hour, 24-hour clock HH 00-23 Hour, 24-hour clock h 1-12 Two-digit hour, 12-hour clock hh 01-12 Hour, 12-hour clock m 0-59 Minute mm 00-59 Minute, 2-digits s 0-59 Second ss 00-59 Second, 2-digits
func (TimeOfDay) IsZero ¶ added in v1.1.0
IsZero reports whether the time of day t is the zero value, 00:00:00.
func (TimeOfDay) MarshalJSON ¶ added in v1.1.0
MarshalJSON implements the json.Marshaler interface. The time of day is a quoted string in RFC 3339 format.
func (TimeOfDay) Nanosecond ¶ added in v1.1.0
Nanosecond returns the nanosecond specified by t.
func (TimeOfDay) String ¶ added in v1.1.0
String returns the textual representation of the time of day.
func (*TimeOfDay) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON implements the json.Unmarshaler interface. The time of day is expected to be a quoted string in RFC 3339 format.