cal: Go (golang) calendar library for dealing with holidays and work days
This library augments the Go time package to provide easy handling of holidays
and work days (business days).
Holiday instances can be exact days, floating days such as the 3rd Monday of
the month, yearly offsets such as the 100th day of the year, or the result of
custom function executions for complex rules.
The Calendar type provides functions for calculating workdays and dealing
with holidays that are observed on alternate days when they fall on weekends.
Here is a simple usage example of a cron job that runs once per day:
package main
import (
"time"
"github.com/rickar/cal"
)
func main() {
c := cal.NewCalendar()
c.AddHoliday(cal.US_Independence)
c.AddHoliday(cal.US_Thanksgiving)
c.AddHoliday(cal.US_Christmas)
t := time.Now()
if c.IsWorkday(t) {
}
if cal.IsWeekend(t) {
}
if c.WorkdaysRemain(t) == 10 {
}
if c.WorkdaysRemain(t) == 0 {
}
}