Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const DateFormat = `2006/01/02`
DateFormat is the date format of the key of the Holidays type.
Variables ¶
View Source
var ( // Catalog is the list of national holidays. In the init(), holidays.json // will be loaded for initialization. Catalog = Holidays{} )
Functions ¶
func IsHoliday ¶
IsHoliday returns the name of a holiday and true if the given time is a national holiday.
Example ¶
testdata := []string{"2021/07/23", "2021/10/10"} for _, v := range testdata { t, err := time.Parse(DateFormat, v) if err != nil { panic(err) } day, ok := IsHoliday(t) fmt.Printf("IsHoliday(%s)= %q, %v\n", v, day, ok) }
Output: IsHoliday(2021/07/23)= "スポーツの日", true IsHoliday(2021/10/10)= "", false
func IsHolidayYYYYMMDD ¶
IsHolidayYYYYMMDD returns the name of a holiday and true if the given date in YYYY/MM/DD format (eg. 2006/01/02) is a national holiday.
Example ¶
testdata := []string{"2021/07/23", "2021/10/10"} for _, v := range testdata { day, ok := IsHolidayYYYYMMDD(v) fmt.Printf("IsHolidayYYYYMMDD(%s)= %q, %v\n", v, day, ok) }
Output: IsHolidayYYYYMMDD(2021/07/23)= "スポーツの日", true IsHolidayYYYYMMDD(2021/10/10)= "", false
Types ¶
Click to show internal directories.
Click to hide internal directories.