Documentation ¶
Overview ¶
Kal is a calendar package for finding public holidays ("red days"), Easter, notable days, equinoxes, solstices and flag flying days.
Index ¶
- func Describe(cal Calendar, date time.Time) string
- func EasterDay(year int) time.Time
- func FlagDay(cal Calendar, date time.Time) bool
- func NotableDay(cal Calendar, date time.Time) bool
- func RedDay(cal Calendar, date time.Time) bool
- func TwoLetterDays(cal Calendar, mondayFirst bool) string
- func WeekNum(date time.Time) int
- type CachedCalendar
- func (calca CachedCalendar) DayName(date time.Weekday) string
- func (calca CachedCalendar) MondayFirst() bool
- func (calca CachedCalendar) MonthName(month time.Month) string
- func (calca CachedCalendar) NormalDay() string
- func (calca CachedCalendar) NotableDay(date time.Time) (bool, string, bool)
- func (calca CachedCalendar) NotablePeriod(date time.Time) (bool, string)
- func (calca CachedCalendar) RedDay(date time.Time) (bool, string, bool)
- type Calendar
- type NorwegianCalendar
- func (nc NorwegianCalendar) DayName(day time.Weekday) string
- func (nc NorwegianCalendar) MondayFirst() bool
- func (nc NorwegianCalendar) MonthName(month time.Month) string
- func (nc NorwegianCalendar) NormalDay() string
- func (nc NorwegianCalendar) NotableDay(date time.Time) (bool, string, bool)
- func (nc NorwegianCalendar) NotablePeriod(date time.Time) (bool, string)
- func (nc NorwegianCalendar) RedDay(date time.Time) (bool, string, bool)
- type TRCalendar
- func (tc TRCalendar) DayName(day time.Weekday) string
- func (tc TRCalendar) DayNameInEnglish(day time.Weekday) string
- func (tc TRCalendar) MondayFirst() bool
- func (tc TRCalendar) MonthName(month time.Month) string
- func (tc TRCalendar) MonthNameInEnglish(month time.Month) string
- func (tc TRCalendar) NormalDay() string
- func (tc TRCalendar) NotableDay(date time.Time) (bool, string, bool)
- func (tc TRCalendar) NotablePeriod(date time.Time) (bool, string)
- func (tc TRCalendar) RedDay(date time.Time) (bool, string, bool)
- type USCalendar
- func (nc USCalendar) DayName(day time.Weekday) string
- func (nc USCalendar) MondayFirst() bool
- func (nc USCalendar) MonthName(month time.Month) string
- func (nc USCalendar) NormalDay() string
- func (nc USCalendar) NotableDay(date time.Time) (bool, string, bool)
- func (nc USCalendar) NotablePeriod(date time.Time) (bool, string)
- func (nc USCalendar) RedDay(date time.Time) (bool, string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NotableDay ¶
Checks if a given date is a notable day or not
func TwoLetterDays ¶
Return a space separated string of the two first letters of every weekday
Types ¶
type CachedCalendar ¶
type CachedCalendar struct {
// contains filtered or unexported fields
}
A CachedCalendar wraps and caches a Calendar
func NewCachedCalendar ¶
func NewCachedCalendar(cal Calendar) CachedCalendar
Creates a new CachedCalendar that wraps and caches the given Calendar. A CachedCalendar is also a Calendar itself, since it implements the Calendar interface.
func (CachedCalendar) DayName ¶
func (calca CachedCalendar) DayName(date time.Weekday) string
Wraps the DayName function
func (CachedCalendar) MondayFirst ¶
func (calca CachedCalendar) MondayFirst() bool
func (CachedCalendar) MonthName ¶
func (calca CachedCalendar) MonthName(month time.Month) string
Wraps the MonthName function
func (CachedCalendar) NormalDay ¶
func (calca CachedCalendar) NormalDay() string
Wraps the NormalDay function
func (CachedCalendar) NotableDay ¶
Wraps the NotableDay function and caches some of the results
func (CachedCalendar) NotablePeriod ¶
func (calca CachedCalendar) NotablePeriod(date time.Time) (bool, string)
Wraps the NotablePeriod function
type Calendar ¶
type Calendar interface { DayName(time.Weekday) string RedDay(time.Time) (bool, string, bool) NotableDay(time.Time) (bool, string, bool) NormalDay() string NotablePeriod(time.Time) (bool, string) MonthName(time.Month) string MondayFirst() bool }
Calendar provides a common interface for calendars of all languages and locales
type NorwegianCalendar ¶
type NorwegianCalendar struct{}
func NewNorwegianCalendar ¶
func NewNorwegianCalendar() NorwegianCalendar
Create a new Norwegian calendar
func (NorwegianCalendar) DayName ¶
func (nc NorwegianCalendar) DayName(day time.Weekday) string
Finds the Norwegian name for a day of the week. Note that time.Weekday starts at 0 with Sunday, not Monday.
func (NorwegianCalendar) MondayFirst ¶
func (nc NorwegianCalendar) MondayFirst() bool
func (NorwegianCalendar) MonthName ¶
func (nc NorwegianCalendar) MonthName(month time.Month) string
Finds the Norwegian name for a given month
func (NorwegianCalendar) NotableDay ¶
Some days are not red, but special in one way or another. Checks if a given date is notable. Returns true/false if the given date is notable, a comma separated description (in case there are more than one notable event that day) and true/false depending on if it's a flag flying day or not.
func (NorwegianCalendar) NotablePeriod ¶
func (nc NorwegianCalendar) NotablePeriod(date time.Time) (bool, string)
Checks if a given date is in a notable time range (summer holidays, for instance)
type TRCalendar ¶
type TRCalendar struct{}
func (TRCalendar) DayName ¶
func (tc TRCalendar) DayName(day time.Weekday) string
Finds the TR name for a day of the week. Note that time.Weekday starts at 0 with Sunday, not Monday.
func (TRCalendar) DayNameInEnglish ¶
func (tc TRCalendar) DayNameInEnglish(day time.Weekday) string
Finds the english name for a day of the week. Note that time.Weekday starts at 0 with Sunday, not Monday.
func (TRCalendar) MondayFirst ¶
func (tc TRCalendar) MondayFirst() bool
func (TRCalendar) MonthName ¶
func (tc TRCalendar) MonthName(month time.Month) string
Finds the TR name for a given month
func (TRCalendar) MonthNameInEnglish ¶
func (tc TRCalendar) MonthNameInEnglish(month time.Month) string
Finds the english name for a given month
func (TRCalendar) NotableDay ¶
Some days are not red, but special in one way or another. Checks if a given date is notable. Returns true/false if the given date is notable, a comma separated description (in case there are more than one notable event that day) and true/false depending on if it's a flag flying day or not.
func (TRCalendar) NotablePeriod ¶
func (tc TRCalendar) NotablePeriod(date time.Time) (bool, string)
Checks if a given date is in a notable time range (summer holidays, for instance)
type USCalendar ¶
type USCalendar struct{}
func (USCalendar) DayName ¶
func (nc USCalendar) DayName(day time.Weekday) string
Finds the US name for a day of the week. Note that time.Weekday starts at 0 with Sunday, not Monday.
func (USCalendar) MondayFirst ¶
func (nc USCalendar) MondayFirst() bool
func (USCalendar) MonthName ¶
func (nc USCalendar) MonthName(month time.Month) string
Finds the US name for a given month
func (USCalendar) NotableDay ¶
Some days are not red, but special in one way or another. Checks if a given date is notable. Returns true/false if the given date is notable, a comma separated description (in case there are more than one notable event that day) and true/false depending on if it's a flag flying day or not.
func (USCalendar) NotablePeriod ¶
func (nc USCalendar) NotablePeriod(date time.Time) (bool, string)
Checks if a given date is in a notable time range (summer holidays, for instance)