Exemple #1
0
 def test_init(self):
     self.assertEqual(relativedelta(date(2014, 1, 7), date(2014, 1, 3)),
                      relativedelta(days=4, bdays=2))
     self.assertEqual(relativedelta(date(2014, 1, 31), date(2014, 1, 1)),
                      relativedelta(days=30, bdays=22))
     self.assertEqual(relativedelta(date(2014, 2, 1), date(2014, 1, 1)),
                      relativedelta(months=1, bdays=23))
     self.assertEqual(relativedelta(date(2014, 2, 2), date(2014, 1, 1)),
                      relativedelta(months=1, days=1, bdays=23))
     self.assertEqual(relativedelta(date(2014, 1, 1), date(2014, 2, 2)),
                      relativedelta(months=-1, days=-1, bdays=-23))
Exemple #2
0
 def test_init(self):
     self.assertEqual(relativedelta(date(2014, 1, 7), date(2014, 1, 3)),
                      relativedelta(days=4, bdays=2))
     self.assertEqual(relativedelta(date(2014, 1, 31), date(2014, 1, 1)),
                      relativedelta(days=30, bdays=22))
     self.assertEqual(relativedelta(date(2014, 2, 1), date(2014, 1, 1)),
                      relativedelta(months=1, bdays=23))
     self.assertEqual(relativedelta(date(2014, 2, 2), date(2014, 1, 1)),
                      relativedelta(months=1, days=1, bdays=23))
     self.assertEqual(relativedelta(date(2014, 1, 1), date(2014, 2, 2)),
                      relativedelta(months=-1, days=-1, bdays=-23))
Exemple #3
0
 def test_radd_time(self):
     self.assertEqual("2015-01-02 16:45" + relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 9, 15))
     self.assertEqual(date(2015, 1, 2) + relativedelta(bminutes=+30),
                      datetime(2015, 1, 2, 9, 30))
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=1, bhours=4),
                      datetime(2014, 1, 6, 13, 0))
     relativedelta.btstart = time(7, 30)
     self.assertEqual("2015-01-02 16:45" + relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 7, 45))
     self.assertEqual("2015-01-02 16:45" + relativedelta(bhours=+0.5),
                      datetime(2015, 1, 5, 7, 45))
     del relativedelta.btstart
Exemple #4
0
 def test_add(self):
     rd1 = relativedelta(years=+1,
                         months=+2,
                         bdays=+3,
                         days=+4,
                         bhours=+5,
                         bminutes=+6,
                         bseconds=+7,
                         hours=+8,
                         minutes=+9,
                         seconds=+10)
     rd2 = relativedelta(years=+10,
                         months=-9,
                         bdays=+8,
                         days=-7,
                         bhours=+6,
                         bminutes=-5,
                         bseconds=+4,
                         hours=-3,
                         minutes=+2,
                         seconds=-1)
     rd3 = relativedelta(years=+11,
                         months=-7,
                         bdays=+11,
                         days=-3,
                         bhours=+11,
                         bminutes=+1,
                         bseconds=+11,
                         hours=+5,
                         minutes=+11,
                         seconds=+9)
     self.assertEqual(rd1 + rd2, rd3)
     self.assertEqual(
         relativedelta(bdays=3) + date(2014, 1, 3), date(2014, 1, 8))
     rd4 = relativedelta(years=+1, months=+2, days=+1)
     rd5 = relativedelta(years=+12,
                         months=-5,
                         bdays=+11,
                         days=-2,
                         bhours=+11,
                         bminutes=+1,
                         bseconds=+11,
                         hours=+5,
                         minutes=+11,
                         seconds=+9)
     self.assertEqual(rd3 + rd4, rd5)
     self.assertEqual(
         date("2014-01-01") + relativedelta(weekday=FR), date(2014, 1, 3))
     self.assertEqual(
         datetime("2014-11-15 1:23") + relativedelta(bdays=1),
         datetime(2014, 11, 18, 1, 23))
Exemple #5
0
 def test_radd_time(self):
     self.assertEqual("2015-01-02 16:45" + relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 9, 15))
     self.assertEqual(
         date(2015, 1, 2) + relativedelta(bminutes=+30),
         datetime(2015, 1, 2, 9, 30))
     self.assertEqual(
         date(2014, 1, 3) + relativedelta(bdays=1, bhours=4),
         datetime(2014, 1, 6, 13, 0))
     relativedelta.btstart = time(7, 30)
     self.assertEqual("2015-01-02 16:45" + relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 7, 45))
     self.assertEqual("2015-01-02 16:45" + relativedelta(bhours=+0.5),
                      datetime(2015, 1, 5, 7, 45))
     del relativedelta.btstart
 def test_start_end(self):
     dt = datetime(2016, 12, 30, 5)
     self.assertEqual(dt.day_start(), datetime(2016, 12, 30, 0))
     self.assertEqual(dt.day_end(),
                      datetime(2016, 12, 30, 23, 59, 59, 999999))
     self.assertEqual(dt.month_start(), datetime(2016, 12, 1, 0))
     self.assertEqual(dt.month_end(),
                      datetime(2016, 12, 31, 23, 59, 59, 999999))
     self.assertEqual(dt.year_start(), datetime(2016, 1, 1, 0))
     self.assertEqual(dt.year_end(),
                      datetime(2016, 12, 31, 23, 59, 59, 999999))
     d = date(2015, 2, 13)
     self.assertEqual(d.month_start(), date(2015, 2, 1))
     self.assertEqual(d.month_end(), date(2015, 2, 28))
     self.assertEqual(d.year_start(), date(2015, 1, 1))
     self.assertEqual(d.year_end(), date(2015, 12, 31))
Exemple #7
0
 def test_start_end(self):
     dt = datetime(2016, 12, 30, 5)
     self.assertEqual(dt.day_start(), datetime(2016, 12, 30, 0))
     self.assertEqual(dt.day_end(),
                      datetime(2016, 12, 30, 23, 59, 59, 999999))
     self.assertEqual(dt.month_start(), datetime(2016, 12, 1, 0))
     self.assertEqual(dt.month_end(),
                      datetime(2016, 12, 31, 23, 59, 59, 999999))
     self.assertEqual(dt.year_start(), datetime(2016, 1, 1, 0))
     self.assertEqual(dt.year_end(),
                      datetime(2016, 12, 31, 23, 59, 59, 999999))
     d = date(2015, 2, 13)
     self.assertEqual(d.month_start(), date(2015, 2, 1))
     self.assertEqual(d.month_end(), date(2015, 2, 28))
     self.assertEqual(d.year_start(), date(2015, 1, 1))
     self.assertEqual(d.year_end(), date(2015, 12, 31))
 def test_radd_time(self):
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 9, 15))
     self.assertEqual(date(2015, 1, 2) + relativedelta(bminutes=+30),
                      datetime(2015, 1, 2, 9, 30))
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=1, bhours=4),
                      datetime(2014, 1, 6, 13, 0))
     bdateutil.BTSTART = time(7, 30)
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 7, 45))
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bhours=+0.5),
                      datetime(2015, 1, 5, 7, 45))
     bdateutil.BTSTART = time(9, 0)
Exemple #9
0
 def test_radd_time(self):
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 9, 15))
     self.assertEqual(date(2015, 1, 2) + relativedelta(bminutes=+30),
                      datetime(2015, 1, 2, 9, 30))
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=1, bhours=4),
                      datetime(2014, 1, 6, 13, 0))
     bdateutil.BTSTART = time(7, 30)
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bminutes=+30),
                      datetime(2015, 1, 5, 7, 45))
     self.assertEqual(datetime("2015-01-02 16:45") +
                      relativedelta(bhours=+0.5),
                      datetime(2015, 1, 5, 7, 45))
     bdateutil.BTSTART = time(9, 0)
 def test_bdays_zero(self):
     self.assertEqual(date("2014-11-15") + relativedelta(bdays=0),
                      date(2014, 11, 17))
     self.assertEqual(date("2014-11-17") + relativedelta(bdays=0),
                      date(2014, 11, 17))
     self.assertEqual(date("2014-11-15") - relativedelta(bdays=0),
                      date(2014, 11, 14))
     self.assertEqual(date("2014-11-14") - relativedelta(bdays=0),
                      date(2014, 11, 14))
Exemple #11
0
 def test_bdays_zero(self):
     self.assertEqual(date("2014-11-15") + relativedelta(bdays=0),
                      date(2014, 11, 17))
     self.assertEqual(date("2014-11-17") + relativedelta(bdays=0),
                      date(2014, 11, 17))
     self.assertEqual(date("2014-11-15") - relativedelta(bdays=0),
                      date(2014, 11, 14))
     self.assertEqual(date("2014-11-14") - relativedelta(bdays=0),
                      date(2014, 11, 14))
 def test_rsub(self):
     self.assertEqual(date(2014, 1, 7) - relativedelta(bdays=2),
                      date(2014, 1, 3))
     self.assertEqual(date(2014, 1, 3) - relativedelta(bdays=-2),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 2, 3) - relativedelta(bdays=19),
                      date(2014, 1, 7))
     self.assertEqual(date("2014-11-15") - relativedelta(bdays=1),
                      date(2014, 11, 14))
     self.assertEqual(date.today() - relativedelta(bdays=+45),
                      date.today() + relativedelta(bdays=-45))
Exemple #13
0
 def test_rsub(self):
     self.assertEqual(date(2014, 1, 7) - relativedelta(bdays=2),
                      date(2014, 1, 3))
     self.assertEqual(date(2014, 1, 3) - relativedelta(bdays=-2),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 2, 3) - relativedelta(bdays=19),
                      date(2014, 1, 7))
     self.assertEqual(date("2014-11-15") - relativedelta(bdays=1),
                      date(2014, 11, 14))
     self.assertEqual(date.today() - relativedelta(bdays=+45),
                      date.today() + relativedelta(bdays=-45))
 def test_init(self):
     self.assertEqual(relativedelta(date(2014, 1, 7), date(2014, 1, 3)),
                      relativedelta(days=4, bdays=2))
     self.assertEqual(relativedelta(date(2014, 1, 31), date(2014, 1, 1)),
                      relativedelta(days=30, bdays=22))
     self.assertEqual(relativedelta(date(2014, 2, 1), date(2014, 1, 1)),
                      relativedelta(months=1, bdays=22))
     self.assertEqual(relativedelta(date(2014, 2, 2), date(2014, 1, 1)),
                      relativedelta(months=1, days=1, bdays=22))
     self.assertEqual(relativedelta(date(2014, 1, 1), date(2014, 2, 2)),
                      relativedelta(months=-1, days=-1, bdays=-22))
     self.assertEqual(relativedelta(datetime(2017, 1, 16),
                                    datetime(2017, 1, 16),
                                    holidays=holidays.US()),
                      relativedelta(bdays=0))
     self.assertEqual(relativedelta(datetime(2017, 1, 17),
                                    datetime(2017, 1, 16),
                                    holidays=holidays.US()),
                      relativedelta(days=1, bdays=0))
Exemple #15
0
 def test_radd(self):
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=2),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 1, 7) + relativedelta(bdays=-2),
                      date(2014, 1, 3))
     self.assertEqual(date(2014, 2, 3) + relativedelta(bdays=-19),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=1.5),
                      datetime(2014, 1, 6, 13, 0))
 def test_radd(self):
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=2),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 1, 7) + relativedelta(bdays=-2),
                      date(2014, 1, 3))
     self.assertEqual(date(2014, 2, 3) + relativedelta(bdays=-19),
                      date(2014, 1, 7))
     self.assertEqual(date(2014, 1, 3) + relativedelta(bdays=1.5),
                      datetime(2014, 1, 6, 13, 0))
Exemple #17
0
 def test_add(self):
     rd1 = relativedelta(years=+1, months=+2, bdays=+3, days=+4,
                         bhours=+5, bminutes=+6, bseconds=+7,
                         hours=+8, minutes=+9, seconds=+10)
     rd2 = relativedelta(years=+10, months=-9, bdays=+8, days=-7,
                         bhours=+6, bminutes=-5, bseconds=+4,
                         hours=-3, minutes=+2, seconds=-1)
     rd3 = relativedelta(years=+11, months=-7, bdays=+11, days=-3,
                         bhours=+11, bminutes=+1, bseconds=+11,
                         hours=+5, minutes=+11, seconds=+9)
     self.assertEqual(rd1 + rd2, rd3)
     self.assertEqual(relativedelta(bdays=3) + date(2014, 1, 3),
                      date(2014, 1, 8))
     rd4 = relativedelta(years=+1, months=+2, days=+1)
     rd5 = relativedelta(years=+12, months=-5, bdays=+11, days=-2,
                         bhours=+11, bminutes=+1, bseconds=+11,
                         hours=+5, minutes=+11, seconds=+9)
     self.assertEqual(rd3 + rd4, rd5)
     self.assertEqual(date("2014-01-01") + relativedelta(weekday=FR),
                      date(2014, 1, 3))
     self.assertEqual(datetime("2014-11-15 1:23") + relativedelta(bdays=1),
                      datetime(2014, 11, 18, 1, 23))
Exemple #18
0
 def test_WORKDAYS(self):
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3),
                      date(2017, 1, 9))
     bdateutil.WORKDAYS = (0, 1, 2)  # Mon, Tues, Wed
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3),
                      date(2017, 1, 11))
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3,
                                                       workdays=(0,)),
                      date(2017, 1, 30))
     bdateutil.WORKDAYS = range(5)
     self.assertRaises(ValueError,
                       lambda: date(2017, 1, 4) +
                       relativedelta(bdays=3, workdays=()))
     self.assertRaises(ValueError,
                       lambda: date(2017, 1, 4) +
                       relativedelta(bdays=3, workdays=('x', 'y')))
 def test_WORKDAYS(self):
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3),
                      date(2017, 1, 9))
     bdateutil.WORKDAYS = (0, 1, 2)  # Mon, Tues, Wed
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3),
                      date(2017, 1, 11))
     self.assertEqual(date(2017, 1, 4) + relativedelta(bdays=3,
                                                       workdays=(0,)),
                      date(2017, 1, 30))
     bdateutil.WORKDAYS = range(5)
     self.assertRaises(ValueError,
                       lambda: date(2017, 1, 4) +
                       relativedelta(bdays=3, workdays=()))
     self.assertRaises(ValueError,
                       lambda: date(2017, 1, 4) +
                       relativedelta(bdays=3, workdays=('x', 'y')))
 def test_date(self):
     self.assertEqual(date("2015-03-25"), dt.date(2015, 3, 25))
     self.assertEqual(date("1/2/2014"), dt.date(2014, 1, 2))
     self.assertEqual(date(1388577600), dt.date(2014, 1, 1))
     self.assertRaises(ValueError, lambda: date("abc"))
     self.assertRaises(TypeError, lambda: date(['a', 'b', 'c']))
     self.assertRaises(TypeError, lambda: date(time(3, 40)))
     self.assertEqual(date(2015, 2, 15).month_end(), date(2015, 2, 28))
     self.assertEqual(date.today(), dt.date.today())
     self.assertEqual(date.today(days=+1),
                      dt.date.today() + relativedelta(days=+1))
     self.assertEqual(date.today(bdays=+200, holidays=holidays.US()),
                      dt.date.today() +
                      relativedelta(bdays=+200, holidays=holidays.US()))
     relativedelta.holidays = holidays.US()
     self.assertEqual(date.today(bdays=+200),
                      dt.date.today() + relativedelta(bdays=+200))
     del relativedelta.holidays
Exemple #21
0
 def test_date(self):
     self.assertEqual(date("2015-03-25"), dt.date(2015, 3, 25))
     self.assertEqual(date("1/2/2014"), dt.date(2014, 1, 2))
     self.assertEqual(date(1388577600), dt.date(2014, 1, 1))
     self.assertRaises(ValueError, lambda: date("abc"))
     self.assertRaises(TypeError, lambda: date(['a', 'b', 'c']))
     self.assertRaises(TypeError, lambda: date(time(3, 40)))
     self.assertEqual(date(2015, 2, 15).month_end(), date(2015, 2, 28))
     self.assertEqual(date.today(), dt.date.today())
     self.assertEqual(date.today(days=+1),
                      dt.date.today() + relativedelta(days=+1))
     self.assertEqual(date.today(bdays=+200, holidays=holidays.US()),
                      dt.date.today() +
                      relativedelta(bdays=+200, holidays=holidays.US()))
     relativedelta.holidays = holidays.US()
     self.assertEqual(date.today(bdays=+200),
                      dt.date.today() + relativedelta(bdays=+200))
     del relativedelta.holidays
 def test_isbday(self):
     self.assertFalse(isbday(date(2014, 1, 4)))
     self.assertFalse(isbday("2014-01-04"))
     self.assertTrue(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday("2014-01-01"))
     self.assertFalse(isbday(date(2014, 1, 1), holidays=holidays.US()))
     self.assertTrue(isbday(datetime(2014, 1, 1, 16, 30)))
     self.assertTrue(isbday(datetime(2014, 1, 1, 17, 30)))
     self.assertFalse(isbday(datetime(2014, 1, 1, 16, 30),
                      holidays=holidays.US()))
     self.assertFalse(isbday(datetime(2014, 1, 1, 17, 30),
                      holidays=holidays.US()))
     bdateutil.HOLIDAYS = holidays.Canada()
     self.assertFalse(isbday(date(2014, 7, 1)))
     self.assertTrue(isbday(date(2014, 7, 4)))
     self.assertFalse(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday(date(2014, 7, 1), holidays=holidays.US()))
     self.assertFalse(isbday(date(2014, 7, 4), holidays=holidays.US()))
     bdateutil.HOLIDAYS = []
Exemple #23
0
 def test_isbday(self):
     self.assertFalse(isbday(date(2014, 1, 4)))
     self.assertFalse(isbday("2014-01-04"))
     self.assertTrue(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday("2014-01-01"))
     self.assertFalse(isbday(date(2014, 1, 1), holidays=holidays.US()))
     self.assertTrue(isbday(datetime(2014, 1, 1, 16, 30)))
     self.assertTrue(isbday(datetime(2014, 1, 1, 17, 30)))
     self.assertFalse(isbday(datetime(2014, 1, 1, 16, 30),
                      holidays=holidays.US()))
     self.assertFalse(isbday(datetime(2014, 1, 1, 17, 30),
                      holidays=holidays.US()))
     bdateutil.HOLIDAYS = holidays.Canada()
     self.assertFalse(isbday(date(2014, 7, 1)))
     self.assertTrue(isbday(date(2014, 7, 4)))
     self.assertFalse(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday(date(2014, 7, 1), holidays=holidays.US()))
     self.assertFalse(isbday(date(2014, 7, 4), holidays=holidays.US()))
     bdateutil.HOLIDAYS = []
Exemple #24
0
 def test_add_sub(self):
     self.assertEqual(datetime("2014-11-15 1:23").add(bdays=1),
                      datetime(2014, 11, 18, 1, 23))
     self.assertEqual(datetime("2014-11-15 1:23").sub(bdays=-1),
                      datetime(2014, 11, 18, 1, 23))
     self.assertEqual(date(2016, 1, 1).add(hours=2, minutes=4),
                      datetime(2016, 1, 1, 2, 4))
     self.assertEqual(datetime(2016, 1, 1, 0).sub(days=1),
                      datetime(2015, 12, 31, 0))
     ush = holidays.US()
     self.assertEqual(date(2016, 12, 30).add(bdays=1, holidays=ush),
                      date(2017, 1, 3))
     self.assertEqual(date(2016, 12, 31).add(bdays=0, holidays=ush),
                      date(2017, 1, 3))
     self.assertEqual(date(2016, 12, 31).add(bdays=1, holidays=ush),
                      date(2017, 1, 4))
     self.assertEqual(time(3, 40).add(hours=5, minutes=25), time(9, 5))
 def test_add_sub(self):
     self.assertEqual(datetime("2014-11-15 1:23").add(bdays=1),
                      datetime(2014, 11, 18, 1, 23))
     self.assertEqual(datetime("2014-11-15 1:23").sub(bdays=-1),
                      datetime(2014, 11, 18, 1, 23))
     self.assertEqual(date(2016, 1, 1).add(hours=2, minutes=4),
                      datetime(2016, 1, 1, 2, 4))
     self.assertEqual(datetime(2016, 1, 1, 0).sub(days=1),
                      datetime(2015, 12, 31, 0))
     ush = holidays.US()
     self.assertEqual(date(2016, 12, 30).add(bdays=1, holidays=ush),
                      date(2017, 1, 3))
     self.assertEqual(date(2016, 12, 31).add(bdays=0, holidays=ush),
                      date(2017, 1, 3))
     self.assertEqual(date(2016, 12, 31).add(bdays=1, holidays=ush),
                      date(2017, 1, 4))
     self.assertEqual(time(3, 40).add(hours=5, minutes=25), time(9, 5))
Exemple #26
0
 def test_isbday(self):
     self.assertFalse(isbday(date(2014, 1, 4)))
     self.assertFalse(isbday("2014-01-04"))
     self.assertTrue(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday("2014-01-01"))
     self.assertFalse(isbday(date(2014, 1, 1), holidays=holidays.US()))
     self.assertTrue(isbday(datetime(2014, 1, 1, 16, 30)))
     self.assertTrue(isbday(datetime(2014, 1, 1, 17, 30)))
     self.assertFalse(isbday(datetime(2014, 1, 1, 16, 30),
                      holidays=holidays.US()))
     self.assertFalse(isbday(datetime(2014, 1, 1, 17, 30),
                      holidays=holidays.US()))
     isbday.holidays = holidays.US()
     self.assertFalse(isbday(date(2014, 1, 1)))
     self.assertFalse(isbday(date(2014, 7, 4)))
     self.assertTrue(isbday(date(2014, 7, 4), holidays=holidays.CA()))
Exemple #27
0
 def test_isbday(self):
     self.assertFalse(isbday(date(2014, 1, 4)))
     self.assertFalse(isbday("2014-01-04"))
     self.assertTrue(isbday(date(2014, 1, 1)))
     self.assertTrue(isbday("2014-01-01"))
     self.assertFalse(isbday(date(2014, 1, 1), holidays=holidays.US()))
     self.assertTrue(isbday(datetime(2014, 1, 1, 16, 30)))
     self.assertTrue(isbday(datetime(2014, 1, 1, 17, 30)))
     self.assertFalse(
         isbday(datetime(2014, 1, 1, 16, 30), holidays=holidays.US()))
     self.assertFalse(
         isbday(datetime(2014, 1, 1, 17, 30), holidays=holidays.US()))
     isbday.holidays = holidays.US()
     self.assertFalse(isbday(date(2014, 1, 1)))
     self.assertFalse(isbday(date(2014, 7, 4)))
     self.assertTrue(isbday(date(2014, 7, 4), holidays=holidays.CA()))
 def test_week(self):
     self.assertEqual(date("2016-12-20").week, 51)
 def test_timestamp(self):
     self.assertEqual(parse(1388577600).date(), date(2014, 1, 1))
Exemple #30
0
 def test_timestamp(self):
     self.assertEqual(parse(1388577600).date(), date(2014, 1, 1))
Exemple #31
0
 def test_week(self):
     self.assertEqual(date("2016-12-20").week, 51)
from bdateutil.easter import easter
from bdateutil.easter import EASTER_WESTERN, EASTER_ORTHODOX, EASTER_JULIAN

from bdateutil import date

try:
    import unittest2 as unittest
except ImportError:
    import unittest

# List of easters between 1990 and 2050
western_easter_dates = [
    date(1990, 4, 15),
    date(1991, 3, 31),
    date(1992, 4, 19),
    date(1993, 4, 11),
    date(1994, 4, 3),
    date(1995, 4, 16),
    date(1996, 4, 7),
    date(1997, 3, 30),
    date(1998, 4, 12),
    date(1999, 4, 4),
    date(2000, 4, 23),
    date(2001, 4, 15),
    date(2002, 3, 31),
    date(2003, 4, 20),
    date(2004, 4, 11),
    date(2005, 3, 27),
    date(2006, 4, 16),
    date(2007, 4, 8),
    date(2008, 3, 23),
Exemple #33
0
 def test_eomday(self):
     self.assertEqual(date("2015-02-15").eomday, dt.date(2015, 2, 28))
     self.assertEqual(datetime("2015-03-01 12:34").eomday,
                      dt.datetime(2015, 3, 31, 12, 34))
Exemple #34
0
from bdateutil.easter import easter
from bdateutil.easter import EASTER_WESTERN, EASTER_ORTHODOX, EASTER_JULIAN

from bdateutil import date

try:
    import unittest2 as unittest
except ImportError:
    import unittest

# List of easters between 1990 and 2050
western_easter_dates = [
    date(1990, 4, 15), date(1991, 3, 31), date(1992, 4, 19), date(1993, 4, 11),
    date(1994, 4,  3), date(1995, 4, 16), date(1996, 4,  7), date(1997, 3, 30),
    date(1998, 4, 12), date(1999, 4,  4),

    date(2000, 4, 23), date(2001, 4, 15), date(2002, 3, 31), date(2003, 4, 20),
    date(2004, 4, 11), date(2005, 3, 27), date(2006, 4, 16), date(2007, 4,  8),
    date(2008, 3, 23), date(2009, 4, 12),

    date(2010, 4,  4), date(2011, 4, 24), date(2012, 4,  8), date(2013, 3, 31),
    date(2014, 4, 20), date(2015, 4,  5), date(2016, 3, 27), date(2017, 4, 16),
    date(2018, 4,  1), date(2019, 4, 21),

    date(2020, 4, 12), date(2021, 4,  4), date(2022, 4, 17), date(2023, 4,  9),
    date(2024, 3, 31), date(2025, 4, 20), date(2026, 4,  5), date(2027, 3, 28),
    date(2028, 4, 16), date(2029, 4,  1),

    date(2030, 4, 21), date(2031, 4, 13), date(2032, 3, 28), date(2033, 4, 17),
    date(2034, 4,  9), date(2035, 3, 25), date(2036, 4, 13), date(2037, 4,  5),
    date(2038, 4, 25), date(2039, 4, 10),
Exemple #35
0
 def test_eomday(self):
     self.assertEqual(date("2015-02-15").eomday, dt.date(2015, 2, 28))
     self.assertEqual(
         datetime("2015-03-01 12:34").eomday,
         dt.datetime(2015, 3, 31, 12, 34))