From e398aec39251ca3d18c649cac9251e80c64fb5b4 Mon Sep 17 00:00:00 2001 From: Rinat Almakhov Date: Sun, 8 Aug 2021 14:29:50 +0200 Subject: [PATCH] barbados #83 --- america/argentina/init.go | 2 -- america/barbados/barbados.go | 49 ++++++++++++++++++++++++++++++++++ america/barbados/holidays.yaml | 17 ++++++++++++ america/barbados/init.go | 3 +++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 america/barbados/barbados.go create mode 100644 america/barbados/holidays.yaml create mode 100644 america/barbados/init.go diff --git a/america/argentina/init.go b/america/argentina/init.go index 08d5376..0538845 100644 --- a/america/argentina/init.go +++ b/america/argentina/init.go @@ -1,5 +1,3 @@ -// +build ignore - package argentina //go:generate go run ../../generator/gen.go -templ ../../generator/calendar.templ diff --git a/america/barbados/barbados.go b/america/barbados/barbados.go new file mode 100644 index 0000000..25d909d --- /dev/null +++ b/america/barbados/barbados.go @@ -0,0 +1,49 @@ +// Code generated github.com/Gasoid/workalendar/generator/gen.go DO NOT EDIT. +package barbados + +import ( + "fmt" + "time" + + core "github.com/Gasoid/workalendar" +) + +var ( + holidays = core.Holidays{ + "1/21": core.Event("Errol Barrow Day"), + "4/28": core.Event("National Heroes Day"), + "11/30": core.Event("Independance Day"), + "12/26": core.Event("Boxing Day"), + } + calendar = core.NewCalendar( + holidays, + core.WithNewYearDay(), + core.WithLabourDay(), + core.WithGoodFriday(), + core.WithEasterMonday(), + core.WithEasterSunday(), + core.WithWhitMonday(), + ) +) + +//IsWorkingDay is inteded to check whether a day is working or not +func IsWorkingDay(date time.Time) bool { + return calendar.IsWorkingDay(date) +} + +//IsHoliday is inteded to check whether a day is holiday or not +func IsHoliday(date time.Time) bool { + return calendar.IsHoliday(date) +} + +//GetHoliday is inteded to check whether a day is holiday or not +func GetHoliday(date time.Time) (*core.CalEvent, error) { + if !IsHoliday(date) { + return nil, fmt.Errorf("there is no holiday for %s", date) + } + holiday := calendar.GetHoliday(date) + if holiday == nil { + return nil, fmt.Errorf("there is no holiday for %s", date) + } + return calendar.GetHoliday(date), nil +} diff --git a/america/barbados/holidays.yaml b/america/barbados/holidays.yaml new file mode 100644 index 0000000..715a47d --- /dev/null +++ b/america/barbados/holidays.yaml @@ -0,0 +1,17 @@ +country: barbados +holidays: + - name: "Errol Barrow Day" + day: "1/21" + - name: "National Heroes Day" + day: "4/28" + - name: "Independance Day" + day: "11/30" + - name: "Boxing Day" + day: "12/26" +include: + - "NewYearDay" + - "LabourDay" + - "GoodFriday" + - "EasterMonday" + - "EasterSunday" + - "WhitMonday" diff --git a/america/barbados/init.go b/america/barbados/init.go new file mode 100644 index 0000000..50b2647 --- /dev/null +++ b/america/barbados/init.go @@ -0,0 +1,3 @@ +package barbados + +//go:generate go run ../../generator/gen.go -templ ../../generator/calendar.templ