calendar

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

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

func FormatYear(y Year) string

FormatYear returns a textual representation of the Year value formatted.

func FormatYearMonth

func FormatYearMonth(ym YearMonth) string

FormatYearMonth returns a textual representation of the YearMonth value formatted.

func FormatYearWeek

func FormatYearWeek(yw YearWeek) string

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 DateOfYD

func DateOfYD(year int, dayOfYear int) Date

func DateOfYMD

func DateOfYMD(year int, month Month, dayOfMonth int) Date

func DateOfYWD

func DateOfYWD(year int, week int, dayOfWeek DayOfWeek) 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. 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.

func UnixDay

func UnixDay(epochDays int64) Date

func (Date) Add

func (d Date) Add(days int) Date

func (Date) After

func (d Date) After(other Date) bool

func (Date) Before

func (d Date) Before(other Date) bool

func (Date) Cmp

func (d Date) Cmp(other Date) int

func (Date) DaysUntil

func (d Date) DaysUntil(endExclusive Date) int64

func (Date) Equal

func (d Date) Equal(other Date) bool

func (Date) String

func (d Date) String() string

func (Date) Sub

func (d Date) Sub(days int) Date

func (Date) UnixDay

func (d Date) UnixDay() int64

func (Date) YD

func (d Date) YD() (year int, dayOfYear int)

func (Date) YMD

func (d Date) YMD() (year int, month Month, day int)

func (Date) YWD

func (d Date) YWD() (year int, week int, dayOfWeek DayOfWeek)

func (Date) Year

func (d Date) Year() Year

func (Date) YearMonth

func (d Date) YearMonth() YearMonth

func (Date) YearWeek

func (d Date) YearWeek() YearWeek

type DateFormat

type DateFormat int
const (
	DateFormatAny DateFormat = iota
	DateFormatYMD
	DateFormatYWD
	DateFormatYD
)

type DayOfWeek

type DayOfWeek int
const (
	DayOfWeekUnspecified DayOfWeek = iota // Unspecified
	DayOfWeekMonday                       // Monday
	DayOfWeekTuesday                      // Tuesday
	DayOfWeekWednesday                    // Wednesday
	DayOfWeekThursday                     // Thursday
	DayOfWeekFriday                       // Friday
	DayOfWeekSaturday                     // Saturday
	DayOfWeekSunday                       // Sunday
)

func (DayOfWeek) String

func (i DayOfWeek) String() string

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
)

func (Month) String

func (i Month) String() string

type Year

type Year int

func ParseYear

func ParseYear(s string) (Year, error)

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 (y Year) ContainsDay(dayOfYear int) bool

func (Year) ContainsWeek

func (y Year) ContainsWeek(week int) bool

func (Year) Date

func (y Year) Date(dayOfYear int) Date

func (Year) Days

func (y Year) Days() int

func (Year) FirstDate

func (y Year) FirstDate() Date

func (Year) FirstMonth

func (y Year) FirstMonth() YearMonth

func (Year) FirstWeek

func (y Year) FirstWeek() YearWeek

func (Year) IsLeap

func (y Year) IsLeap() bool

func (Year) LastDate

func (y Year) LastDate() Date

func (Year) LastMonth

func (y Year) LastMonth() YearMonth

func (Year) LastWeek

func (y Year) LastWeek() YearWeek

func (Year) Month

func (y Year) Month(month Month) YearMonth

func (Year) String

func (y Year) String() string

func (Year) Week

func (y Year) Week(weekOfYear int) YearWeek

func (Year) Weeks

func (y Year) Weeks() int

type YearMonth

type YearMonth struct {
	// contains filtered or unexported fields
}

func ParseYearMonth

func ParseYearMonth(s string) (YearMonth, error)

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 YearMonthOf(year int, month Month) YearMonth

func (YearMonth) Add

func (ym YearMonth) Add(months int) YearMonth

func (YearMonth) After

func (ym YearMonth) After(other YearMonth) bool

func (YearMonth) Before

func (ym YearMonth) Before(other YearMonth) bool

func (YearMonth) Cmp

func (ym YearMonth) Cmp(other YearMonth) int

func (YearMonth) ContainsDay

func (ym YearMonth) ContainsDay(dayOfMonth int) bool

func (YearMonth) Date

func (ym YearMonth) Date(dayOfMonth int) Date

func (YearMonth) Days

func (ym YearMonth) Days() int

func (YearMonth) Equal

func (ym YearMonth) Equal(other YearMonth) bool

func (YearMonth) FirstDate

func (ym YearMonth) FirstDate() Date

func (YearMonth) LastDate

func (ym YearMonth) LastDate() Date

func (YearMonth) MonthsUntil

func (ym YearMonth) MonthsUntil(endExclusive YearMonth) int64

func (YearMonth) String

func (ym YearMonth) String() string

func (YearMonth) Sub

func (ym YearMonth) Sub(months int) YearMonth

func (YearMonth) Year

func (ym YearMonth) Year() Year

func (YearMonth) YyyyMm

func (ym YearMonth) YyyyMm() (year int, month Month)

type YearWeek

type YearWeek struct {
	// contains filtered or unexported fields
}

func ParseYearWeek

func ParseYearWeek(s string) (YearWeek, error)

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.

func YearWeekOf

func YearWeekOf(year int, week int) YearWeek

func (YearWeek) After

func (yw YearWeek) After(other YearWeek) bool

func (YearWeek) Before

func (yw YearWeek) Before(other YearWeek) bool

func (YearWeek) Cmp

func (yw YearWeek) Cmp(other YearWeek) int

func (YearWeek) Date

func (yw YearWeek) Date(dayOfWeek DayOfWeek) Date

func (YearWeek) Equal

func (yw YearWeek) Equal(other YearWeek) bool

func (YearWeek) FirstDate

func (yw YearWeek) FirstDate() Date

func (YearWeek) LastDate

func (yw YearWeek) LastDate() Date

func (YearWeek) String

func (yw YearWeek) String() string

func (YearWeek) Year

func (yw YearWeek) Year() Year

func (YearWeek) YyyyWw

func (yw YearWeek) YyyyWw() (year int, week int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL