Documentation
¶
Index ¶
- func FormatDate(d Date, format DateFormat) string
- func FormatYear(y Year) string
- func FormatYearMonth(ym YearMonth) string
- func FormatYearWeek(yw YearWeek) string
- type Date
- func (d Date) Add(days int) Date
- func (d Date) After(other Date) bool
- func (d Date) Before(other Date) bool
- func (d Date) Cmp(other Date) int
- func (d Date) DaysUntil(endExclusive Date) int64
- func (d Date) Equal(other Date) bool
- func (d Date) String() string
- func (d Date) Sub(days int) Date
- func (d Date) UnixDay() int64
- func (d Date) YD() (year int, dayOfYear int)
- func (d Date) YMD() (year int, month Month, day int)
- func (d Date) YWD() (year int, week int, dayOfWeek DayOfWeek)
- func (d Date) Year() Year
- func (d Date) YearMonth() YearMonth
- func (d Date) YearWeek() YearWeek
- type DateFormat
- type DayOfWeek
- type Month
- type Year
- func (y Year) ContainsDay(dayOfYear int) bool
- func (y Year) ContainsWeek(week int) bool
- func (y Year) Date(dayOfYear int) Date
- func (y Year) Days() int
- func (y Year) FirstDate() Date
- func (y Year) FirstMonth() YearMonth
- func (y Year) FirstWeek() YearWeek
- func (y Year) IsLeap() bool
- func (y Year) LastDate() Date
- func (y Year) LastMonth() YearMonth
- func (y Year) LastWeek() YearWeek
- func (y Year) Month(month Month) YearMonth
- func (y Year) String() string
- func (y Year) Week(weekOfYear int) YearWeek
- func (y Year) Weeks() int
- type YearMonth
- func (ym YearMonth) Add(months int) YearMonth
- func (ym YearMonth) After(other YearMonth) bool
- func (ym YearMonth) Before(other YearMonth) bool
- func (ym YearMonth) Cmp(other YearMonth) int
- func (ym YearMonth) ContainsDay(dayOfMonth int) bool
- func (ym YearMonth) Date(dayOfMonth int) Date
- func (ym YearMonth) Days() int
- func (ym YearMonth) Equal(other YearMonth) bool
- func (ym YearMonth) FirstDate() Date
- func (ym YearMonth) LastDate() Date
- func (ym YearMonth) MonthsUntil(endExclusive YearMonth) int64
- func (ym YearMonth) String() string
- func (ym YearMonth) Sub(months int) YearMonth
- func (ym YearMonth) YM() (year int, month Month)
- func (ym YearMonth) Year() Year
- type YearWeek
- func (yw YearWeek) After(other YearWeek) bool
- func (yw YearWeek) Before(other YearWeek) bool
- func (yw YearWeek) Cmp(other YearWeek) int
- func (yw YearWeek) Date(dayOfWeek DayOfWeek) Date
- func (yw YearWeek) Equal(other YearWeek) bool
- func (yw YearWeek) FirstDate() Date
- func (yw YearWeek) LastDate() Date
- func (yw YearWeek) String() string
- func (yw YearWeek) YW() (year int, week int)
- func (yw YearWeek) Year() Year
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDate ¶
func FormatDate(d Date, format DateFormat) string
FormatDate returns a textual representation of the Date value formatted according to the format defined by the argument.
func FormatYear ¶
FormatYear returns a textual representation of the Year value formatted.
func FormatYearMonth ¶
FormatYearMonth returns a textual representation of the YearMonth value formatted.
func FormatYearWeek ¶
FormatYearWeek returns a textual representation of the YearWeek value formatted.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date represents a date in the proleptic Gregorian calendar. The zero value is 0001-01-01.
func DateOfYD ¶
DateOfYD returns a Date of the given year and day of year. It panics if the arguments represents an invalid date.
func DateOfYMD ¶
DateOfYMD returns a Date of the given year, month, and day of month. It panics if the arguments represents an invalid date.
func DateOfYWD ¶
DateOfYWD returns a Date of the given year, week, and day of week. It panics if the arguments represents an invalid date.
func ParseDate ¶
func ParseDate(s string, format DateFormat) (d Date, err error)
ParseDate parses a formatted string and returns the Date value it represents.
type DateFormat ¶
type DateFormat int
DateFormat represents the format of a date. The following formats are supported:
- DateFormatYMD: yyyy-mm-dd - DateFormatYWD: yyyy-Www-d - DateFormatYD: yyyy-ddd
where y, m, d, and w are decimal digits and W is a rune 'W'. Each of the above formats may have a prefix of '-' or '+' for the sign of the year.
const ( // DateFormatAny represents any date format. DateFormatAny DateFormat = iota // DateFormatYMD represents the yyyy-mm-dd format. DateFormatYMD // DateFormatYWD represents the yyyy-Www-d format. DateFormatYWD // DateFormatYD represents the yyyy-ddd format. DateFormatYD )
type Month ¶
type Month int
Month represents a month.
const ( MonthUnspecified Month = iota // Unspecified MonthJanuary // January MonthFebruary // February MonthMarch // March MonthApril // April MonthMay // May MonthJune // June MonthJuly // July MonthAugust // August MonthSeptember // September MonthOctober // October MonthNovember // November MonthDecember // December )
type Year ¶
type Year int
Year represents a year.
func ParseYear ¶
ParseYear parses a formatted string and returns the Year value it represents. The following format is supported:
- yyyy:
where y is a decimal digit. The above format may have a prefix of '-' or '+' for the sign of the year.
func (Year) ContainsDay ¶
ContainsDay returns true if the dayOfYear is in this year.
func (Year) ContainsWeek ¶
ContainsWeek returns true if the week is in this year.
func (Year) FirstMonth ¶
FirstMonth returns the first month in this year.
type YearMonth ¶
type YearMonth struct {
// contains filtered or unexported fields
}
YearMonth represents a year and a month in the proleptic Gregorian calendar.
func ParseYearMonth ¶
ParseYearMonth parses a formatted string and returns the YearMonth value it represents. The following format is supported:
- yyyy-mm
where y and m are decimal digits. The above format may have a prefix of '-' or '+' for the sign of the year.
func YearMonthOf ¶
YearMonthOf returns a YearMonth of the given year and month.
func (YearMonth) After ¶
After returns whether the year and month is after the other year and month.
func (YearMonth) Before ¶
Before returns whether the year and month is before the other year and month.
func (YearMonth) ContainsDay ¶
ContainsDay returns true if the dayOfMonth is in this year and month.
func (YearMonth) Equal ¶
Equal returns whether the year and month is equal to the other year and month.
func (YearMonth) MonthsUntil ¶
MonthsUntil returns the number of months until the year and month of endExclusive.
type YearWeek ¶
type YearWeek struct {
// contains filtered or unexported fields
}
YearWeek represents a year and a week.
func ParseYearWeek ¶
ParseYearWeek parses a formatted string and returns the YearWeek value it represents. The following format is supported:
- year-week:
- yyyy-Www:
where y and w are a decimal digits and W is a rune 'W'. The above format may have a prefix of '-' or '+' for the sign of the year.
func YearWeekOf ¶
YearWeekOf returns a YearWeek of the given year and week.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cmd/testcases/date/addsub
command
|
|
|
cmd/testcases/date/compare
command
|
|
|
cmd/testcases/date/conv
command
|
|
|
cmd/testcases/date/until
command
|
|
|
cmd/testcases/date/yyyyddd
command
|
|
|
cmd/testcases/date/yyyymmdd
command
|
|
|
cmd/testcases/date/yyyywwd
command
|
|
|
cmd/testcases/yearmonth/addsub
command
|
|
|
cmd/testcases/yearmonth/compare
command
|
|
|
cmd/testcases/yearmonth/conv
command
|
|
|
cmd/testcases/yearmonth/day
command
|
|
|
cmd/testcases/yearmonth/until
command
|
|
|
cmd/testcases/yearmonth/yyyymm
command
|
|
|
cmd/testcases/yearweek/compare
command
|
|
|
cmd/testcases/yearweek/conv
command
|
|
|
cmd/testcases/yearweek/day
command
|
|
|
cmd/testcases/yearweek/yyyyww
command
|
|