mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
38 lines
751 B
Go
38 lines
751 B
Go
package bamboohr
|
|
|
|
type Calendar struct {
|
|
Items []Item `xml:"item"`
|
|
}
|
|
|
|
/* -------------------- Public Functions -------------------- */
|
|
|
|
func (calendar *Calendar) Holidays() []Item {
|
|
return calendar.filteredItems("holiday")
|
|
}
|
|
|
|
func (calendar *Calendar) ItemsByType(itemType string) []Item {
|
|
if itemType == "timeOff" {
|
|
return calendar.TimeOffs()
|
|
}
|
|
|
|
return calendar.Holidays()
|
|
}
|
|
|
|
func (calendar *Calendar) TimeOffs() []Item {
|
|
return calendar.filteredItems("timeOff")
|
|
}
|
|
|
|
/* -------------------- Private Functions -------------------- */
|
|
|
|
func (calendar *Calendar) filteredItems(itemType string) []Item {
|
|
items := []Item{}
|
|
|
|
for _, item := range calendar.Items {
|
|
if item.Type == itemType {
|
|
items = append(items, item)
|
|
}
|
|
}
|
|
|
|
return items
|
|
}
|