holiday

package
v0.0.0-...-847d61e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package holiday contains functions for working with holidays.

While the majority of holidays occur on either a particular date (eg the 25th) or on a particular day (eg the fourth Thursday), Easter is calculated from a combination of integer arithmetic and Divine Intervention, which is why it gets its own file. Good Friday lives in that file as well.

The package is (currently, mainly) built around us.go, which contains functions to calculate holidays that are observed in the United States. It contains functions for calculating the 11 federal holidays: that's the 10 you know plus Inauguration Day, which is observed only in DC to mitigate traffic. Each of those functions implements the Finder type.

The List type is an array of Finder functions and has functions to identify a given time.Time as a holiday or observed holiday. There are premade lists for US federal holidays (aka bank holidays or "days everyone else gets off") and trading holidays: days the stock markets are closed. More information about the federal and trading holidays can be found at <https://www.redcort.com/us-federal-bank-holidays> and <https://www.nyse.com/markets/hours-calendars>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlackFriday

func BlackFriday(year ...int) time.Time

BlackFriday returns the date of Black Friday. Black Friday is the day after Thanksgiving and might as well be a Federal holiday.

func Check

func Check(date time.Time, against *List) bool

Check whether the given date is a work holiday

func CheckExact

func CheckExact(date time.Time, against *List) bool

CheckExact whether the given date is an actual holiday. This function differs from the Check function in that it does not consider observed holidays.

func ChristmasDay

func ChristmasDay(year ...int) time.Time

ChristmasDay returns the date of Christmas Day. Christmas Day is Dec 25, and a Federal holiday.

func ChristmasEve

func ChristmasEve(year ...int) time.Time

ChristmasEve returns the date of Christmas Eve. Christmas Eve is the day before Christmas (Day) and might as well be a Federal holiday.

func ColumbusDay

func ColumbusDay(year ...int) time.Time

ColumbusDay returns the date of Columbus Day. Columbus Day is the second Monday in October and a Federal holiday.

func Easter

func Easter(year ...int) time.Time

Easter returns the date of Western Easter for the given year. In Western Christianity, Easter Sunday is the first Sunday after the first full moon after the Equinox. Generally the Paschal full moon (the first after the Equinox) happens shortly after the Equinox, so Easter subsequently happens around the end of March.

func GoodFriday

func GoodFriday(year ...int) time.Time

GoodFriday returns the date of Good Friday for the given year.

func InaugurationDay

func InaugurationDay(year ...int) time.Time

InaugurationDay returns the date of the next Inauguration Day. Inauguration Day is January 20th, the date the new POTUS is swon in. As it only happens every four years, the function will return the date of the "next" one; these years can be represented as (y % 4 == 1). If 2016 or 2017 is passed as a parameter, for example, the function will return Jan 20, 2017. If 2018 is passed, the function will return Jan 20, 2021.

func IndependenceDay

func IndependenceDay(year ...int) time.Time

IndependenceDay returns the date of Independence Day. Independence Day is aka July 4. It is not a Federal Holiday (just kidding!)

func LaborDay

func LaborDay(year ...int) time.Time

LaborDay returns the date of Labor Day. Labor Day is the first Monday in September and a Federal holiday.

func MLKDay

func MLKDay(year ...int) time.Time

MLKDay returns the date of Martin Luther King Day. MLK Day is the third Monday in January and is a Federal holiday.

func MemorialDay

func MemorialDay(year ...int) time.Time

MemorialDay returns the date of Memorial Day. Memorial Day is the last Monday in May and a Federal holiday.

func NYDay

func NYDay(year ...int) time.Time

NYDay returns the date of New Year's Day. If it falls on a weekend, it is observed the following Monday.

func NYEve

func NYEve(year ...int) time.Time

NYEve returns the date of New Year's Eve. New Year's Eve is the day before Christmas (Day) and might as well be a Federal holiday.

func Observed

func Observed(holiday time.Time) time.Time

Observed returns the observed date of a holiday. Generally if a holiday falls on a Saturday it is observed the preceeding Friday, and if it falls on a Sunday it is observed the following Monday. The only exception to this rule is New Year's Day, which is observed the following Monday when it occurs on a Saturday.

func PresidentsDay

func PresidentsDay(year ...int) time.Time

PresidentsDay returns the date of President's Day. President's Day is the third Monday in February and a Federal holiday.

func Thanksgiving

func Thanksgiving(year ...int) time.Time

Thanksgiving returns the date of Thanksgiving. Thanksgiving is the fourth Thursday in November and a Federal holiday.

func VeteransDay

func VeteransDay(year ...int) time.Time

VeteransDay returns the date of Veteran's Day. Veteran's Day is Nov 11, and a Federal holiday.

Types

type Finder

type Finder func(year ...int) time.Time

Finder is an interface for holiday calculation functions. Each function should accept an optional integer parameter for the year and return the date of the holiday. If a parameter is not specified, the function should calculate the date of the holiday for the current year. The returned time should be in local time (ie time.Local) with zeroes for hours, minutes, seconds, and nanoseconds.

type List

type List []Finder

List represents a list of holiday Finders

FederalHolidays are days the US government takes off. The USPS and banks tend to observe these holidays as well. This list does not include Inauguration Day, as it is only a holiday under very specific circumstances.

TradingHolidays are days the US stock markets are closed. This list does not include the days the markets close early: on July 3, the day before Thanksgiving, and Christmas Eve the markets close at 1pm ET.

func (*List) Contains

func (l *List) Contains(date time.Time) bool

Contains checks if <date> exists in the List.

func (*List) Observes

func (l *List) Observes(date time.Time) bool

Observes checks if <date> is an observed holiday.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL