How to use the holidays.NZ 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_hawkes_bay_anniversary_day(self):
        hkb_holidays = holidays.NZ(prov="Hawke's Bay")
        for year, day in enumerate([19, 25, 24, 22, 21,        # 2001-05
                                    20, 19, 24, 23, 22,        # 2006-10
                                    21, 19, 25, 24, 23,        # 2011-15
                                    21, 20, 19, 25, 23, 22],   # 2016-21
                                   2001):
            dt = date(year, 10, day)
            self.assertTrue(dt in hkb_holidays, dt)
            self.assertEqual(hkb_holidays[dt],
                             "Hawke's Bay Anniversary Day")
github dr-prodigy / python-holidays / tests.py View on Github external
def test_southland_anniversary_day(self):
        stl_holidays = holidays.NZ(prov='Southland')
        for year, day in enumerate([15, 14, 20, 19, 17,        # 2001-05
                                    16, 15, 14, 19, 18, 17],   # 2006-11
                                   2001):
            dt = date(year, 1, day)
            self.assertTrue(dt in stl_holidays, dt)
            self.assertEqual(stl_holidays[dt],
                             "Southland Anniversary Day", dt)
            for year, (month, day) in enumerate([(4, 10), (4,  2), (4, 22),
                                                 (4,  7), (3, 29), (4, 18),
                                                 (4,  3), (4, 23), (4, 14),
                                                 (4,  6)], 2012):
                dt = date(year, month, day)
                self.assertTrue(dt in stl_holidays, dt)
                self.assertEqual(stl_holidays[dt],
                                 "Southland Anniversary Day", dt)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_westland_anniversary_day(self):
        wtc_holidays = holidays.NZ(prov='Westland')
        for year, day in enumerate([3,   2,  1, 29,  5,        # 2001-05
                                    4,   3,  1, 30, 29,        # 2006-10
                                    28,  3,  2,  1, 30,        # 2011-15
                                    28,  4,  3,  2, 30, 29],   # 2016-21
                                   2001):
            dt = date(year, 12 if day < 9 else 11, day)
            self.assertTrue(dt in wtc_holidays, dt)
            self.assertEqual(wtc_holidays[dt],
                             "Westland Anniversary Day", dt)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_auckland_anniversary_day(self):
        auk_holidays = holidays.NZ(prov='Auckland')
        for year, day in enumerate([29, 28, 27, 26, 31,        # 2001-05
                                    30, 29, 28, 26,  1,        # 2006-10
                                    31, 30, 28, 27, 26,        # 2011-15
                                    1,  30, 29, 28, 27,  1],   # 2016-21
                                   2001):
            dt = date(year, 2 if day < 9 else 1, day)
            self.assertTrue(dt in auk_holidays, dt)
            self.assertEqual(auk_holidays[dt],
                             "Auckland Anniversary Day")
github dr-prodigy / python-holidays / tests.py View on Github external
def test_waitangi_day(self):
        ntl_holidays = holidays.NZ(prov='Northland')
        for year, day in enumerate([3, 8, 7, 6, 5], 1964):
            dt = date(year, 2, day)
            self.assertTrue(dt in ntl_holidays, dt)
            self.assertEqual(ntl_holidays[dt][:8], "Waitangi")
        for year in range(1900, 1974):
            dt = date(year, 2, 6)
            self.assertFalse(dt in self.holidays)
        for year in range(1974, 2100):
            dt = date(year, 2, 6)
            self.assertTrue(dt in self.holidays)
        for year, day in enumerate([6, 6, 6, 6, 6,       # 2001-05
                                    6, 6, 6, 6, 6,       # 2006-10
                                    6, 6, 6, 6, 6,       # 2011-15
                                    8, 6, 6, 6, 6, 8],   # 2016-21
                                   2001):
            dt = date(year, 2, day)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_nelson_anniversary_day(self):
        nsn_holidays = holidays.NZ(prov='Nelson')
        for year, day in enumerate([29,  4,  3,  2, 31,        # 2001-05
                                    30, 29,  4,  2,  1,        # 2006-10
                                    31, 30,  4,  3,  2,        # 2011-15
                                    1,  30, 29,  4,  3,  1],   # 2016-21
                                   2001):
            dt = date(year, 2 if day < 9 else 1, day)
            self.assertTrue(dt in nsn_holidays, dt)
            self.assertEqual(nsn_holidays[dt],
                             "Nelson Anniversary Day", dt)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_all_holidays_present(self):
        nz_1969 = sum(holidays.NZ(years=[1969], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_1969 = sum((nz_1969.get_list(key) for key in nz_1969), [])
        nz_2015 = sum(holidays.NZ(years=[2015], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_2015 = sum((nz_2015.get_list(key) for key in nz_2015), [])
        nz_1974 = sum(holidays.NZ(years=[1974], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_1974 = sum((nz_1974.get_list(key) for key in nz_1974), [])
        all_holidays = ["New Year's Day",
                        "Day after New Year's Day",
                        "Waitangi Day",
                        "Good Friday",
                        "Easter Monday",
                        "Anzac Day",
                        "Queen's Birthday",
                        "Labour Day",
github dr-prodigy / python-holidays / tests.py View on Github external
def setUp(self):
        self.holidays = holidays.NZ(observed=True)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_all_holidays_present(self):
        nz_1969 = sum(holidays.NZ(years=[1969], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_1969 = sum((nz_1969.get_list(key) for key in nz_1969), [])
        nz_2015 = sum(holidays.NZ(years=[2015], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_2015 = sum((nz_2015.get_list(key) for key in nz_2015), [])
        nz_1974 = sum(holidays.NZ(years=[1974], prov=p)
                      for p in holidays.NZ.PROVINCES)
        holidays_in_1974 = sum((nz_1974.get_list(key) for key in nz_1974), [])
        all_holidays = ["New Year's Day",
                        "Day after New Year's Day",
                        "Waitangi Day",
                        "Good Friday",
                        "Easter Monday",
                        "Anzac Day",
                        "Queen's Birthday",
                        "Labour Day",
                        "Christmas Day",
                        "Boxing Day",
                        "Auckland Anniversary Day",
                        "Taranaki Anniversary Day",
github dr-prodigy / python-holidays / tests.py View on Github external
def test_taranaki_anniversary_day(self):
        tki_holidays = holidays.NZ(prov='Taranaki')
        for year, day in enumerate([12, 11, 10,  8, 14,        # 2001-05
                                    13, 12, 10,  9,  8,        # 2006-10
                                    14, 12, 11, 10,  9,        # 2011-15
                                    14, 13, 12, 11,  9,  8],   # 2016-21
                                   2001):
            dt = date(year, 3, day)
            self.assertTrue(dt in tki_holidays, dt)
            self.assertEqual(tki_holidays[dt],
                             "Taranaki Anniversary Day")