Skip to content

wlbr/feiertage

Repository files navigation

Feiertage

Feiertage is a Go/Golang library for calculating German and Austrian bank holidays. It includes the calculation of the date of Easter and, more importantly, offers ways to retrieve public holidays for a state of Germany or Austria (=Bundesland).

The library is probably useful only for people realizing use cases with special requirements inside of Austria or Germany, such as shift schedules or capacity calculation.

Documentation

See https://pkg.go.dev/github.com/wlbr/feiertage

Usage:

There are two types of functions:

  • <feiertag>(year) and
  • <region>(year optional:IncludingSundays:true)

<feiertag> returns an extended time object (type feiertag). It carries the date of the holiday in the requested year plus the name of the holiday. <feiertag> may be any of the following:

Neujahr Epiphanias
HeiligeDreiKönige Weltknuddeltag
InternationalerTagDesGedenkensAnDieOpferDesHolocaust Weiberfastnacht
Valentinstag Karnevalssonntag
Rosenmontag Fastnacht
Aschermittwoch InternationalerFrauentag
Josefitag Palmsonntag
BeginnSommerzeit Gründonnerstag
Karfreitag Ostern
Ostermontag TagDerErde
Walpurgisnacht Staatsfeiertag
TagDerArbeit InternationalerTagDerPressefreiheit
StarWarsDay Florianitag
TagDerBefreiung Muttertag
Vatertag ChristiHimmelfahrt
Pfingsten Handtuchtag
Pfingstmontag TowelDay
Dreifaltigkeitssonntag InternationalerKindertag
Fronleichnam Weltumwelttag
TagDesMeeres Weltspieltag
Weltblutspendetag Weltflüchtlingstag
FêteDeLaMusique InternationalerTagGegenDrogenmissbrauch
SystemAdministratorAppreciationDay MariäHimmelfahrt
Antikriegstag Weltkindertag
HobbitDay Rupertitag
TagDerDeutschenEinheit Erntedankfest
TagDerVolksabstimmung BeginnWinterzeit
Nationalfeiertag Halloween
Reformationstag Allerheiligen
Allerseelen Weltmännertag
Martinstag Karnevalsbeginn
Volkstrauertag Leopolditag
BußUndBettag InternationalerMännertag
Totensontag Thanksgiving
Blackfriday ErsterAdvent
Nikolaus ZweiterAdvent
MariäEmpfängnis MariäUnbefleckteEmpfängnis
DritterAdvent VierterAdvent
Heiligabend Christtag
Weihnachten Stefanitag
ZweiterWeihnachtsfeiertag Silvester

<region> returns an object of type region. It offers a list of public holidays valid in the specified state as well as the name and the shortname of the state as attributes. <region> may be any of:

BadenWürttemberg Bayern Berlin
Brandenburg Bremen Hamburg
Hessen MecklenburgVorpommern Niedersachsen
NordrheinWestfalen RheinlandPfalz Saarland
Sachsen SachsenAnhalt SchleswigHolstein
Thüringen Deutschland Burgenland
Kärnten Niederösterreich Oberösterreich
Salzburg Steiermark Tirol
Vorarlberg Wien Österreich
All    

The optional region function argument includingSundays switches the behavior of the region function to include "gesetzliche Feiertage" that fall on Sundays in its output. This is important in Brandenburg, particularly for Easter and Pentecost Sunday. If you are calculating shift costs you will need to know even the holidays "hidden by Sunday".

The region functions return the public holidays ("gesetzliche Feiertage"). The function all returns all defined "special dates", such as Penance Day (Buß- und Bettag) or the begin/end of daylight saving time.

The regional functions for Austrian Bundesländer include saints' days which are state-level holidays, meaning schools etc. are generally closed but workers don't get the day off by default. If you don't want to include these days in your planning, it's okay to reference Österreich instead, as legal holidays are (more or less) synchronised across all Austrian states (Bundesländer).

Examples:

fmt.Println(Ostern(2016))
--> 27.03.2016 Ostern


fmt.Println(BußUndBettag(2016))
--> 16.11.2016 Buß- und Bettag



fmt.Println(Brandenburg(2016))
--> Brandenburg (BB)
    01.01.2016 Neujahr
    25.03.2016 Karfreitag
    27.03.2016 Ostern
    28.03.2016 Ostermontag
    01.05.2016 Tag der Arbeit
    05.05.2016 Christi Himmelfahrt
    15.05.2016 Pfingsten
    16.05.2016 Pfingstmontag
    03.10.2016 Tag der deutschen Einheit
    31.10.2016 Reformationstag
    25.12.2016 Weihnachten
    26.12.2016 Zweiter Weihnachtsfeiertag


fmt.Println(Brandenburg(2016, false))
--> Brandenburg (BB)
    01.01.2016 Neujahr
    25.03.2016 Karfreitag
    28.03.2016 Ostermontag
    01.05.2016 Tag der Arbeit
    05.05.2016 Christi Himmelfahrt
    16.05.2016 Pfingstmontag
    03.10.2016 Tag der deutschen Einheit
    31.10.2016 Reformationstag
    25.12.2016 Weihnachten
    26.12.2016 Zweiter Weihnachtsfeiertag

Command line tool

A little command line tool is included as well. It can be compiled using make buildcmd or go build cmd/feiertage/feiertage.go This will create an executable feiertage.

See https://github.com/wlbr/feiertage/releases/latest for downloads.

Synopsis

feiertage: [options] year

-asTaskjugglerCode (default false)
Print the result as valid source code (`leave x y`) for the Taskjuggler planning tool.
-inklusiveSonntage (default false)
Should public holidays on a Sunday be included?
-region <regionstring> (default "All")
Return public holidays for region ``.
<regionstring> may be (case insensitive, plus some other tricks to make it more tolerant):
 BadenWürttemberg
 Bayern
 Berlin
 Brandenburg
 Bremen
 Hamburg
 Hessen
 MecklenburgVorpommern
 Niedersachsen
 NordrheinWestfalen
 RheinlandPfalz
 Saarland
 Sachsen
 SachsenAnhalt
 SchleswigHolstein
 Thüringen
 Deutschland
 Burgenland
 Kärnten
 Niederösterreich
 Oberösterreich
 Salzburg
 Steiermark
 Tirol
 Vorarlberg
 Wien
 Österreich
 All

Code

  • Documentation: Go Reference
  • Continuous Integration: CI
  • Test Coverage: codecov
  • Metrics: GoReportCard

About

Gesetzliche Feiertage und mehr in Deutschland und Österreich (Bank holidays/public holidays in Austria and Germany)

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors