How to use the holidays.HolidayBase function in holidays

To help you get started, we’ve selected a few holidays examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dr-prodigy / python-holidays / tests.py View on Github external
def test_update(self):
        h = holidays.HolidayBase()
        h.update({
            date(2015, 1, 1): "New Year's Day",
            '2015-12-25': "Christmas Day",
        })
        self.assertTrue('2015-01-01' in h)
        self.assertTrue(date(2015, 12, 25) in h)
github facebook / prophet / python / fbprophet / hdays.py View on Github external
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import absolute_import, division, print_function

import warnings
from calendar import Calendar, MONDAY
from datetime import date, timedelta

from convertdate.islamic import from_gregorian, to_gregorian
from holidays import WEEKEND, HolidayBase, easter, rd
from lunarcalendar import Lunar, Converter

# Official public holidays at a country level
# ------------ Holidays in Brazil---------------------
class Brazil(HolidayBase):
    """
    Implement public holidays in Brazil

    Reference:
    https://en.wikipedia.org/wiki/Public_holidays_in_Brazil
    """

    def __init__(self, **kwargs):
        self.country = "BR"
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        # New Year's Day
        if not self.observed and date(year, 1, 1).weekday() in WEEKEND:
            pass
        else:
github dr-prodigy / python-holidays / holidays.py View on Github external
# Remembrance day
            self[date(year, 11, 1)] = "dan spomina na mrtve"

            # Christmas
            self[date(year, 12, 25)] = "Božič"

            # Day of independence and unity
            self[date(year, 12, 26)] = "dan samostojnosti in enotnosti"


class SI(Slovenia):
    pass


class Finland(HolidayBase):
    # https://en.wikipedia.org/wiki/Public_holidays_in_Finland

    def __init__(self, **kwargs):
        self.country = "FI"
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        e = easter(year)

        self[date(year, 1, 1)] = "Uudenvuodenpäivä"
        self[date(year, 1, 6)] = "Loppiainen"
        self[e - rd(days=2)] = "Pitkäperjantai"
        self[e] = "Pääsiäispäivä"
        self[e + rd(days=1)] = "2. pääsiäispäivä"
        self[date(year, 5, 1)] = "Vappu"
        self[e + rd(days=39)] = "Helatorstai"
github dr-prodigy / python-holidays / holidays.py View on Github external
"československého státu"
        if year >= 1990:
            self[date(year, 11, 17)] = "Den boje za svobodu a demokracii"

        if year >= 1990:
            self[date(year, 12, 24)] = "Štědrý den"
        if year >= 1951:
            self[date(year, 12, 25)] = "1. svátek vánoční"
            self[date(year, 12, 26)] = "2. svátek vánoční"


class CZ(Czech):
    pass


class Slovak(HolidayBase):
    # https://sk.wikipedia.org/wiki/Sviatok
    # https://www.slov-lex.sk/pravne-predpisy/SK/ZZ/1993/241/20160101

    def __init__(self, **kwargs):
        self.country = 'SK'
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        self[date(year, 1, 1)] = "Deň vzniku Slovenskej republiky" \

        self[date(year, 1, 6)] = "Zjavenie Pána (Traja králi a vianočný" \
            "sviatok pravoslávnych kresťanov)"

        e = easter(year)
        self[e - rd(days=2)] = "Veľký piatok"
        self[e + rd(days=1)] = "Veľkonočný pondelok"
github dr-prodigy / python-holidays / holidays.py View on Github external
self[date(year, 8, 15)] = "Maria Himmelfahrt"
        if 1919 <= year <= 1934:
            self[date(year, 11, 12)] = "Nationalfeiertag"
        if year >= 1967:
            self[date(year, 10, 26)] = "Nationalfeiertag"
        self[date(year, 11, 1)] = "Allerheiligen"
        self[date(year, 12, 8)] = "Maria Empfängnis"
        self[date(year, 12, 25)] = "Christtag"
        self[date(year, 12, 26)] = "Stefanitag"


class AT(Austria):
    pass


class Denmark(HolidayBase):
    # https://en.wikipedia.org/wiki/Public_holidays_in_Denmark

    def __init__(self, **kwargs):
        self.country = 'DK'
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        # Public holidays
        self[date(year, 1, 1)] = "Nytårsdag"
        self[easter(year) + rd(weekday=TH(-1))] = "Skærtorsdag"
        self[easter(year) + rd(weekday=FR(-1))] = "Langfredag"
        self[easter(year)] = "Påskedag"
        self[easter(year) + rd(weekday=MO)] = "Anden påskedag"
        self[easter(year) + rd(weekday=FR(+4))] = "Store bededag"
        self[easter(year) + rd(days=39)] = "Kristi himmelfartsdag"
        self[easter(year) + rd(days=49)] = "Pinsedag"
github facebook / prophet / python / fbprophet / hdays.py View on Github external
for offset in range(-1, 2, 1):
            islam_year = from_gregorian(year + offset, 11, 20)[0]
            y, m, d = to_gregorian(islam_year + 1, 3, 12)
            if y == year:
                self[date(y, m, d)] = name

        # Christmas
        self[date(year, 12, 25)] = "Christmas"


class ID(Indonesia):
    pass


# ------------ Holidays in India---------------------
class India(HolidayBase):
    """
    Implement public holidays in India

    Reference:
    https://en.wikipedia.org/wiki/Public_holidays_in_India

    Please note:
    India is a culturally diverse and fervent society, celebrate various
    holidays and festivals. We only implement the holidays that **all states
    and territories** celebrate.
    """

    def __init__(self, **kwargs):
        self.country = "IN"
        HolidayBase.__init__(self, **kwargs)
github facebook / prophet / python / fbprophet / hdays.py View on Github external
def __init__(self, **kwargs):
        self.country = "RU"
        HolidayBase.__init__(self, **kwargs)
github dr-prodigy / python-holidays / holidays.py View on Github external
self[e - rd(days=2)] = "Good Friday"
        self[e + rd(days=1)] = "Easter Monday"
        self[date(year, 5, 1)] = "1 May (Labour Day)"
        self[date(year, 12, 25)] = "Christmas Day"
        self[date(year, 12, 26)] = "26 December"


class ECB(EuropeanCentralBank):
    pass


class TAR(EuropeanCentralBank):
    pass


class Czech(HolidayBase):
    # https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic

    def __init__(self, **kwargs):
        self.country = 'CZ'
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        self[date(year, 1, 1)] = "Den obnovy samostatného českého státu" \
            if year >= 2000 else \
            "Nový rok"

        e = easter(year)
        if year <= 1951 or year >= 2016:
            self[e - rd(days=2)] = "Velký pátek"
        self[e + rd(days=1)] = "Velikonoční pondělí"
github dr-prodigy / python-holidays / holidays.py View on Github external
if self.prov == 'Nouvelle-Calédonie':
            self[date(year, 9, 24)] = 'Fête de la Citoyenneté'

        if self.prov == 'Saint-Barthélémy':
            self[date(year, 10, 9)] = "Abolition de l'esclavage"

        if self.prov == 'La Réunion' and year >= 1981:
            self[date(year, 12, 20)] = "Abolition de l'esclavage"


# FR already exists (Friday), we don't want to mess it up
class FRA(France):
    pass


class Belgium(HolidayBase):
    """
    https://www.belgium.be/nl/over_belgie/land/belgie_in_een_notendop/feestdagen
    https://nl.wikipedia.org/wiki/Feestdagen_in_Belgi%C3%AB
    """
    def __init__(self, **kwargs):
        self.country = "BE"
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):
        # New years
        self[date(year, 1, 1)] = "Nieuwjaarsdag"

        easter_date = easter(year)

        # Easter
        self[easter_date] = "Pasen"
github facebook / prophet / python / fbprophet / hdays.py View on Github external
# Defence Day
        name = "Defence Day"
        self[date(year, 9, 6)] = name

        # Death Anniversary of Quaid-e-Azam
        name = "Death Anniversary of Quaid-e-Azam"
        self[date(year, 9, 11)] = name


class PK(Pakistan):
    pass


# ------------ Holidays in Bangladesh---------------------
class Bangladesh(HolidayBase):
    """
    Implement public holidays in Bangladesh

    Reference:
    https://en.wikipedia.org/wiki/Public_holidays_in_Bangladesh
    """

    def __init__(self, **kwargs):
        self.country = "BD"
        HolidayBase.__init__(self, **kwargs)

    def _populate(self, year):

        # Language Martyrs' Day
        name = "Language Martyrs' Day"
        self[date(year, 2, 21)] = name