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) Year() Year
- func (ym YearMonth) YyyyMm() (year int, month Month)
- 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) Year() Year
- func (yw YearWeek) YyyyWw() (year int, week int)
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 . The zero value represents 0001-01-01
func ParseDate ¶
func ParseDate(s string, format DateFormat) (d Date, err error)
ParseDate parses a formatted string and returns the Date value it represents. The following formats are supported:
- year-month-dayOfMonth:
- yyyy-mm-dd:
- year-dayOfYear:
- yyyy-ddd
- year-week-dayOfWeek:
- yyyy-Www-d
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.
type DateFormat ¶
type DateFormat int
const ( DateFormatAny DateFormat = iota DateFormatYMD DateFormatYWD DateFormatYD )
type Month ¶
type Month int
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
func ParseYear ¶
ParseYear parses a formatted string and returns the Year value it represents. The following format is supported:
- year:
- 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 ¶
func (Year) ContainsWeek ¶
func (Year) FirstMonth ¶
type YearMonth ¶
type YearMonth struct {
// contains filtered or unexported fields
}
func ParseYearMonth ¶
ParseYearMonth parses a formatted string and returns the YearMonth value it represents. The following format is supported:
- year-month:
- 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 ¶
func (YearMonth) ContainsDay ¶
func (YearMonth) MonthsUntil ¶
type YearWeek ¶
type YearWeek struct {
// contains filtered or unexported fields
}
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. The above format may have a prefix of '-' or '+' for the sign of the year.