コード例 #1
0
 def testTESequenceSelectsAnyMemberThatAppliesToTheDate(self):
     # first tuesday and last friday of the month
     fnt = te.temporalExpressionSequence([ \
             te.dayInMonth(2,0) \
             ,te.dayInMonth(5,-1) \
             ])
     dtApplies1 = dt.datetime(2015, 12, 25, 0, 0, 0, tzinfo=tz.utc)
     dtApplies2 = dt.datetime(2015, 2, 3, 0, 0, 0, tzinfo=tz.utc)
     dtDoesNotApply1 = dt.datetime(2015, 2, 4, 0, 0, 0, tzinfo=tz.utc)
     self.assertTrue(fnt(dtApplies1))
     self.assertTrue(fnt(dtApplies2))
     self.assertFalse(fnt(dtDoesNotApply1))
コード例 #2
0
 def testTESequenceSelectsAnyMemberThatAppliesToTheDate(self):
     # first tuesday and last friday of the month
     fnt = te.temporalExpressionSequence([ \
             te.dayInMonth(2,0) \
             ,te.dayInMonth(5,-1) \
             ])
     dtApplies1 = dt.datetime(2015,12,25,0,0,0,tzinfo=tz.utc)
     dtApplies2 = dt.datetime(2015,2,3,0,0,0,tzinfo=tz.utc)
     dtDoesNotApply1 = dt.datetime(2015,2,4,0,0,0,tzinfo=tz.utc)
     self.assertTrue(fnt(dtApplies1))
     self.assertTrue(fnt(dtApplies2))
     self.assertFalse(fnt(dtDoesNotApply1))
コード例 #3
0
 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)
コード例 #4
0
 def testTEIntersectionSelectsOnlyIfDateMatchesAllConditions(self):
     # Tuesday and Friday in March
     fnt = te.temporalExpressionIntersection([ \
             te.temporalExpressionSequence([ \
                 te.dayOfWeek(2), te.dayOfWeek(5)]) \
             , te.rangeInYear(3,1,3,31)])
     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, 4, 0, 0, 0, tzinfo=tz.utc)
     self.assertTrue(fnt(dtApplies1))
     self.assertTrue(fnt(dtApplies2))
     self.assertFalse(fnt(dtDoesNotApply1))
     self.assertFalse(fnt(dtDoesNotApply2))
コード例 #5
0
 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)
コード例 #6
0
 def testTEIntersectionSelectsOnlyIfDateMatchesAllConditions(self):
     # Tuesday and Friday in March
     fnt = te.temporalExpressionIntersection([ \
             te.temporalExpressionSequence([ \
                 te.dayOfWeek(2), te.dayOfWeek(5)]) \
             , te.rangeInYear(3,1,3,31)])
     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,4,0,0,0,tzinfo=tz.utc)
     self.assertTrue(fnt(dtApplies1))
     self.assertTrue(fnt(dtApplies2))
     self.assertFalse(fnt(dtDoesNotApply1))
     self.assertFalse(fnt(dtDoesNotApply2))
コード例 #7
0
 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))
コード例 #8
0
 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))