def testGenerateAllWorkDaysInMarch(self): fnt = te.temporalExpressionDifference( \ te.rangeInYear(3,1,4,1) , te.temporalExpressionSequence([ \ te.dayOfWeek(0), te.dayOfWeek(6)])) dateList = [d for d in de.dateRangeGenerator( \ dt.datetime(2015,3,1,0,0,0, tzinfo=tz.utc) \ ,dt.datetime(2015,4,1,0,0,0, tzinfo=tz.utc)) \ if fnt(d)] self.assertEqual(dateList[0], dt.datetime(2015,3,2,0,0,0, tzinfo=tz.utc)) self.assertEqual(dateList[-1], dt.datetime(2015,3,31,0,0,0, tzinfo=tz.utc)) self.assertEqual(len(dateList), 22)
def testGenerateAllWorkDaysInMarch(self): fnt = te.temporalExpressionDifference( \ te.rangeInYear(3,1,4,1) , te.temporalExpressionSequence([ \ te.dayOfWeek(0), te.dayOfWeek(6)])) dateList = [d for d in de.dateRangeGenerator( \ dt.datetime(2015,3,1,0,0,0, tzinfo=tz.utc) \ ,dt.datetime(2015,4,1,0,0,0, tzinfo=tz.utc)) \ if fnt(d)] self.assertEqual(dateList[0], dt.datetime(2015, 3, 2, 0, 0, 0, tzinfo=tz.utc)) self.assertEqual(dateList[-1], dt.datetime(2015, 3, 31, 0, 0, 0, tzinfo=tz.utc)) self.assertEqual(len(dateList), 22)
def testTEDifferenceExcludesWeekends(self): # Excludes weekends from dates fnt = te.temporalExpressionDifference( \ te.rangeInYear(3,1,3,31) , te.temporalExpressionSequence([ \ te.dayOfWeek(0), te.dayOfWeek(6)])) dtApplies1 = dt.datetime(2015, 3, 24, 0, 0, 0, tzinfo=tz.utc) dtApplies2 = dt.datetime(2015, 3, 6, 0, 0, 0, tzinfo=tz.utc) dtDoesNotApply1 = dt.datetime(2015, 2, 4, 0, 0, 0, tzinfo=tz.utc) dtDoesNotApply2 = dt.datetime(2015, 3, 7, 0, 0, 0, tzinfo=tz.utc) dtDoesNotApply3 = dt.datetime(2015, 3, 29, 0, 0, 0, tzinfo=tz.utc) self.assertTrue(fnt(dtApplies1)) self.assertTrue(fnt(dtApplies2)) self.assertFalse(fnt(dtDoesNotApply1)) self.assertFalse(fnt(dtDoesNotApply2)) self.assertFalse(fnt(dtDoesNotApply3))
def testTEDifferenceExcludesWeekends(self): # Excludes weekends from dates fnt = te.temporalExpressionDifference( \ te.rangeInYear(3,1,3,31) , te.temporalExpressionSequence([ \ te.dayOfWeek(0), te.dayOfWeek(6)])) dtApplies1 = dt.datetime(2015,3,24,0,0,0,tzinfo=tz.utc) dtApplies2 = dt.datetime(2015,3,6,0,0,0,tzinfo=tz.utc) dtDoesNotApply1 = dt.datetime(2015,2,4,0,0,0,tzinfo=tz.utc) dtDoesNotApply2 = dt.datetime(2015,3,7,0,0,0,tzinfo=tz.utc) dtDoesNotApply3 = dt.datetime(2015,3,29,0,0,0,tzinfo=tz.utc) self.assertTrue(fnt(dtApplies1)) self.assertTrue(fnt(dtApplies2)) self.assertFalse(fnt(dtDoesNotApply1)) self.assertFalse(fnt(dtDoesNotApply2)) self.assertFalse(fnt(dtDoesNotApply3))