Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( BadenWuerttemberg = "bw" Bayern = "by" Bavaria = "by" Berlin = "be" Brandenburg = "bb" Bremen = "hb" Hamburg = "hh" Hessen = "he" Hesse = "he" MecklenburgVorpommern = "mv" MecklenburgWesternPomerania = "mv" Niedersachsen = "ni" LowerSaxony = "ni" NordrheinWestfalen = "nw" NorthrhineWestphalia = "nw" RheinlandPfalz = "rp" RhinelandPalatinate = "rp" Saarland = "sl" Sachsen = "sn" Saxony = "sn" SachsenAnhalt = "st" SaxonyAnhalt = "st" SchleswigHolstein = "sh" Thueringen = "th" Thuringia = "th" )
abbreviations aligned to: https://www.datenportal.bmbf.de/portal/de/G122.html
View Source
const (
Any = ""
)
Variables ¶
This section is empty.
Functions ¶
func IsHoliday ¶
IsHoliday returns true if a holiday was found for the given date
Example ¶
package main import ( "fmt" "github.com/Oppodelldog/holiday" "time" ) func main() { var ( date = time.Date(2024, 12, 25, 0, 0, 0, 0, time.Local) result = holiday.IsHoliday(date, holiday.Any) ) if result { fmt.Println("it is a holiday") } else { fmt.Println("sorry, no holiday") } }
Output: it is a holiday
Types ¶
type Entry ¶
type Entry struct { Date string `json:"date"` Name string `json:"name"` States States `json:"states,omitempty"` }
Entry defines one holiday date.
type File ¶
type File struct {
Holidays []Entry `json:"holidays"`
}
File wraps holiday date entries for file serialization.
type Query ¶
type Query struct {
Index IndexByDate
}
Query allows to check for holidays
func (Query) AddFileToIndex ¶
AddFileToIndex adds File data from the given filepath to the actual Query index. Existing entries in the index are overwritten.
func (Query) Find ¶
Find returns a holiday and true if a holiday was found for the given parameters.
func (Query) IsHoliday ¶
IsHoliday returns true if a holiday was found for the given date
Example ¶
package main import ( "fmt" "github.com/Oppodelldog/holiday" "time" ) func main() { var ( date = time.Date(2024, 12, 25, 0, 0, 0, 0, time.Local) query = holiday.New() result = query.IsHoliday(date, holiday.Any) ) if result { fmt.Println("it is a holiday") } else { fmt.Println("sorry, no holiday") } }
Output: it is a holiday
Click to show internal directories.
Click to hide internal directories.