Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ This version only contains (incomplete) holiday information from:
* Brazil
* Poland
* United Kingdom

* Germany

Getting started
===============

To get the latest version you have to clone this repository.

Installation
------------
Expand All @@ -43,6 +44,8 @@ Installation
Usage
-----

**Brazil**

Suppose you want to get the holidays for 2014 in the city of São Paulo,
state of São Paulo, Brazil. You would do this::

Expand Down Expand Up @@ -70,6 +73,36 @@ state of São Paulo, Brazil. You would do this::
datetime.date(2014, 11, 20): 'Dia da Consciência Negra',
datetime.date(2014, 12, 25): 'Natal'}

**Germany**

To get the holidays of Germany you should use the abbreviations for the german federal states like 'Germany/BY ' for Bayern.

:BW: Baden-Württemberg
:BY: Bayern
:BE: Berlin
:BB: Brandenburg
:HB: Bremen
:HH: Hamburg
:HE: Hessen
:MV: Mecklenburg-Vorpommern
:NI: Niedersachsen
:NW: Nordrhein-Westfalen
:RP: Rheinland-Pfalz
:SL: Saarland
:SN: Sachsen
:ST: Sachsen-Anhalt
:SH: Schleswig-Holstein
:TH: Thüringen

Example::

from holiday import get_holidays
adict = holiday.get_holidays(year=2015, place='Germany/BY')
print(adict)

Note
------

We don't currently help calculations involving business days; maybe we should.
But many approaches are possible. See, for instance,
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#custom-business-days-experimental
68 changes: 68 additions & 0 deletions holiday/countries/germany.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-

'''Holiday information for Brazil.'''

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datetime import date, timedelta
from dateutil import easter


def get_holidays(year, place=['Germany', None, None], scope='legal', _=str):
""" Returns German holiday dates. Use the abbreviations for the german
federal states like 'Germany/BY ' for Bayern.
BW: Baden-Württemberg
BY: Bayern
BE: Berlin
BB: Brandenburg
HB: Bremen
HH: Hamburg
HE: Hessen
MV: Mecklenburg-Vorpommern
NI: Niedersachsen
NW: Nordrhein-Westfalen
RP: Rheinland-Pfalz
SL: Saarland
SN: Sachsen
ST: Sachsen-Anhalt
SH: Schleswig-Holstein
TH: Thüringen
Example: get_holidays(year=2015, place='Germany/BY')
"""

eastr = easter.easter(year)

adict = {
date(year, 1, 1): 'Neujahr',
date(year, 5, 1): 'Tag der Arbeit',
date(year, 10, 3): 'Tag der Deutschen Einheit',
date(year, 12, 25): '1. Weihnachtstag',
date(year, 12, 26): '2. Weihnachtstag',
eastr - timedelta(days=2): 'Karfreitag',
eastr: 'Ostersonntag',
eastr + timedelta(days=1): 'Ostermontag',
eastr + timedelta(days=39): 'Christi Himmelfahrt',
eastr + timedelta(days=50): 'Pfingstmontag',
} # These are the *national* holidays.

if place[1].upper() in ('BW', 'BY', 'ST'):
adict[date(year, 1, 6)] = 'Heilige Drei Könige'

if place[1] in ('BW', 'BY', 'HE', 'NW', 'RP', 'SL'):
adict[eastr + timedelta(days=60)] = 'Frohnleichnam'

if place[1].upper() in ('BY', 'SL'):
adict[date(year, 8, 15)] = 'Mariä Himmelfahrt'

if place[1].upper() in ('BB', 'MV', 'SN', 'ST', 'TH'):
adict[date(year, 10, 31)] = 'Reformationstag'

if place[1].upper() in ('BW', 'BY', ):
adict[date(year, 11, 1)] = 'Allerheiligen'

return adict


if __name__ == "__main__":
from pprint import pprint
pprint(get_holidays(2015, place=['Germany', 'BE', 'Berlin']))