Documentation ¶
Index ¶
- type Date
- func FromString(str string) (Date, error)
- func FromTime(t time.Time) Date
- func Max(d1, d2 Date) Date
- func Min(d1, d2 Date) Date
- func MustFromString(str string) Date
- func New(year int, month time.Month, day int) Date
- func Today() Date
- func TodayIn(loc *time.Location) Date
- func Tomorrow() Date
- func TomorrowIn(loc *time.Location) Date
- func Yesterday() Date
- func YesterdayIn(loc *time.Location) 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) Day() int
- func (d Date) DaysInMonth() int
- func (d Date) EndOfMonth() Date
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) Month() time.Month
- func (d *Date) Scan(src interface{}) error
- func (d Date) StartOfMonth() Date
- func (d Date) StartOfNextQuarter() Date
- func (d Date) StartOfQuarter() Date
- func (d Date) String() string
- func (d Date) Time() time.Time
- func (d Date) TimeIn(loc *time.Location) time.Time
- func (d *Date) UnmarshalJSON(p []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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date int
Date represents a calendar day (and thus has day precision). It's stored as the number of days since the epoch date 1970-01-01. It can be negative, to represent dates before the epoch. Because it's a date, it doesn't exist within any particular timezone.
func FromString ¶
FromString creates a date from its ISO8601 (YYYY-MM-DD) representation.
func Max ¶
Max finds the maximum date (furthest in the direction of the future) out of the two given dates.
func Min ¶
Min finds the minimum date (furthest in the direction of the past) out of the two given dates.
func MustFromString ¶
MustFromString creates a date from its ISO8601 (YYYY-MM-DD) representation. It panics if str is not in the right format.
func TomorrowIn ¶
Tomorrow gives tomorrow's date in given timezone.
func YesterdayIn ¶
Yesterday gives yesterday's date in given timezone.
func (Date) AddDays ¶
AddDays adds the number of specified days to create a new date. Since Dates are just integers representing the number of days since 1970-01-01, the usual `+` operator can be used instead.
func (Date) AddMonths ¶
AddMonths adds the number of specified months to create a new date. Dates are normalized in the same way as `AddDate` in the `time` package.
func (Date) AddYears ¶
AddYears adds the number of specified years to create a new date. Dates are normalized in the same way as `AddDate` in the `time` package.
func (Date) DaysInMonth ¶
DaysInMonth gives the number of days in the current month
func (Date) EndOfMonth ¶
EndOfMonth gives the date that is the last day of the current month.
func (Date) MarshalJSON ¶
MarshalJSON marshals the date into a JSON string in ISO8601 format.
func (*Date) Scan ¶
Scan implements the sql.Scanner interface, allowing the sql package to read sql dates into Date.
func (Date) StartOfMonth ¶
StartOfMonth gives the date that is the 1st day of the current month.
func (Date) StartOfNextQuarter ¶
StartOfNextQuarter gives the date that is the 1st day of the next quarter (starting in Jan, Apr, Jul, or Oct).
func (Date) StartOfQuarter ¶
StartOfQuarter gives the date that is the 1st day of the current quarter (starting in Jan, Apr, Jul, or Oct).
func (Date) Time ¶
Time returns a time.Time at midnight at the start of the date in the UTC timezone.
func (Date) TimeIn ¶
TimeIn returns a time.Time at midnight at the start of the date in the Location specified.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON string in the ISO8601 format into a date.
func (Date) Value ¶
Value implements the driver.Valuer interface, allowing sql drivers to send Dates to sql databases.