How to use the holidays.CA 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_st_georges_day(self):
        nl_holidays = holidays.CA(prov="NL")
        for dt in [date(1990, 4, 23), date(1999, 4, 26), date(2000, 4, 24),
                   date(2010, 4, 19), date(2016, 4, 25), date(2020, 4, 20)]:
            self.assertFalse(dt in self.holidays)
            self.assertTrue(dt in nl_holidays)
            self.assertFalse(dt + relativedelta(days=-1) in nl_holidays)
            self.assertFalse(dt + relativedelta(days=+1) in nl_holidays)
github dr-prodigy / python-holidays / tests.py View on Github external
self.assertTrue('2014-07-01' in ca)
        self.assertFalse('2014-07-04' in ca)
        self.assertTrue('2014-07-04' in us)
        self.assertTrue('2014-07-04' in ca+us)
        self.assertTrue('2014-07-04' in us+ca)
        self.assertTrue('2015-07-04' in ca+us)
        self.assertTrue('2015-07-04' in us+ca)
        self.assertTrue('2015-07-01' in ca+us)
        self.assertTrue('2015-07-01' in us+ca)
        self.assertTrue('2014-07-04' in na)
        self.assertTrue('2015-07-04' in na)
        self.assertTrue('2015-07-01' in na)
        self.assertTrue('2000-02-05' in na)
        self.assertEqual((ca+us).prov, 'ON')
        self.assertEqual((us+ca).prov, 'ON')
        ca = holidays.CA(years=[2014], expand=False)
        us = holidays.US(years=[2014, 2015], expand=True)
        self.assertTrue((ca+us).expand)
        self.assertEqual((ca+us).years, set([2014, 2015]))
        self.assertEqual((us+ca).years, set([2014, 2015]))
        na = holidays.CA()
        na += holidays.US()
        na += holidays.MX()
        self.assertEqual(na.country, ['CA', 'US', 'MX'])
        self.assertTrue('2014-07-04' in na)
        self.assertTrue('2014-07-04' in na)
        self.assertTrue('2015-07-04' in na)
        self.assertTrue('2015-07-04' in na)
        self.assertTrue('2015-07-01' in na)
        self.assertTrue('2015-07-01' in na)
        self.assertTrue('2000-02-05' in na)
        self.assertEqual(na.prov, 'ON')
github dr-prodigy / python-holidays / tests.py View on Github external
def test_thanksgiving(self):
        ns_holidays = holidays.CA(prov="NB")
        for dt in [date(1931, 10, 12), date(1990, 10,  8), date(1999, 10, 11),
                   date(2000, 10,  9), date(2013, 10, 14), date(2020, 10, 12)]:
            self.assertTrue(dt in self.holidays)
            self.assertFalse(dt + relativedelta(days=-1) in self.holidays)
            self.assertFalse(dt + relativedelta(days=+1) in self.holidays)
            self.assertFalse(dt in ns_holidays)
github dr-prodigy / python-holidays / tests.py View on Github external
na = ca + (us + mx) + ca + (mx + us + holidays.CA(prov='BC'))
        self.assertTrue('2000-02-05' in na)
        self.assertTrue('2014-02-10' in na)
        self.assertTrue('2014-02-17' in na)
        self.assertTrue('2014-07-04' in na)
        provs = (holidays.CA(prov='ON', years=[2014]) +
                 holidays.CA(prov='BC', years=[2015]))
        self.assertTrue("2015-02-09" in provs)
        self.assertTrue("2015-02-16" in provs)
        self.assertEqual(provs.prov, ['ON', 'BC'])
        a = sum([holidays.CA(prov=x) for x in holidays.CA.PROVINCES])
        self.assertEqual(a.country, 'CA')
        self.assertEqual(a.prov, holidays.CA.PROVINCES)
        self.assertTrue("2015-02-09" in a)
        self.assertTrue("2015-02-16" in a)
        na = holidays.CA() + holidays.US() + holidays.MX()
        self.assertTrue(date(1969, 12, 25) in na)
        self.assertEqual(na.get(date(1969, 7, 1)), "Canada Day")
        self.assertEqual(na.get(date(1969, 12, 25)),
                         "Christmas Day, Navidad [Christmas]")
        na = holidays.MX() + holidays.CA() + holidays.US()
        self.assertEqual(na.get(date(1969, 12, 25)),
                         "Navidad [Christmas], Christmas Day")
github dr-prodigy / python-holidays / tests.py View on Github external
def test_remembrance_day(self):
        ab_holidays = holidays.CA(prov="AB", observed=False)
        nl_holidays = holidays.CA(prov="NL", observed=False)
        self.assertFalse(date(1930, 11, 11) in ab_holidays)
        self.assertFalse(date(1930, 11, 11) in nl_holidays)
        for year in range(1931, 2100):
            dt = date(year, 11, 11)
            self.assertFalse(dt in self.holidays)
            self.assertTrue(dt in ab_holidays)
            self.assertTrue(dt in nl_holidays)
            self.assertFalse(dt + relativedelta(days=-1) in nl_holidays)
            self.assertFalse(dt + relativedelta(days=+1) in nl_holidays)
        self.assertFalse(date(2007, 11, 12) in ab_holidays)
        self.assertFalse(date(2007, 11, 12) in nl_holidays)
        ab_holidays.observed = True
        nl_holidays.observed = True
        self.assertFalse(date(2007, 11, 12) in ab_holidays)
        self.assertTrue(date(2007, 11, 12) in nl_holidays)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_family_day(self):
        ab_holidays = holidays.CA(prov="AB")
        bc_holidays = holidays.CA(prov="BC")
        mb_holidays = holidays.CA(prov="MB")
        sk_holidays = holidays.CA(prov="SK")
        for dt in [date(1990, 2, 19), date(1999, 2, 15), date(2000, 2, 21),
                   date(2006, 2, 20)]:
            self.assertFalse(dt in self.holidays)
            self.assertTrue(dt in ab_holidays)
            self.assertFalse(dt in bc_holidays)
            self.assertFalse(dt in mb_holidays)
            self.assertFalse(dt in sk_holidays)
        dt = date(2007, 2, 19)
        self.assertFalse(dt in self.holidays)
        self.assertTrue(dt in ab_holidays)
        self.assertFalse(dt in bc_holidays)
        self.assertFalse(dt in mb_holidays)
        self.assertTrue(dt in sk_holidays)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_remembrance_day(self):
        ab_holidays = holidays.CA(prov="AB", observed=False)
        nl_holidays = holidays.CA(prov="NL", observed=False)
        self.assertFalse(date(1930, 11, 11) in ab_holidays)
        self.assertFalse(date(1930, 11, 11) in nl_holidays)
        for year in range(1931, 2100):
            dt = date(year, 11, 11)
            self.assertFalse(dt in self.holidays)
            self.assertTrue(dt in ab_holidays)
            self.assertTrue(dt in nl_holidays)
            self.assertFalse(dt + relativedelta(days=-1) in nl_holidays)
            self.assertFalse(dt + relativedelta(days=+1) in nl_holidays)
        self.assertFalse(date(2007, 11, 12) in ab_holidays)
        self.assertFalse(date(2007, 11, 12) in nl_holidays)
        ab_holidays.observed = True
        nl_holidays.observed = True
        self.assertFalse(date(2007, 11, 12) in ab_holidays)
        self.assertTrue(date(2007, 11, 12) in nl_holidays)
github dr-prodigy / python-holidays / tests.py View on Github external
def test_eq_ne(self):
        us1 = holidays.UnitedStates()
        us2 = holidays.US()
        us3 = holidays.UnitedStates(years=[2014])
        us4 = holidays.US(years=[2014])
        ca1 = holidays.Canada()
        ca2 = holidays.CA()
        ca3 = holidays.Canada(years=[2014])
        ca4 = holidays.CA(years=[2014])
        self.assertEqual(us1, us2)
        self.assertEqual(us3, us4)
        self.assertEqual(ca1, ca2)
        self.assertEqual(ca3, ca4)
        self.assertNotEqual(us1, us3)
        self.assertNotEqual(us1, ca1)
        self.assertNotEqual(us3, ca3)
        self.assertTrue(us1 != us3)