def testByMonthDay(self):
     self.failUnlessParseMatches(
         "FREQ=YEARLY;BYMONTH=1,10,11;BYDAY=4SU", True, {
             'freq': rrule.YEARLY,
             'interval': 1,
             'bymonth': (1, 10, 11),
             'byweekday': (rrule.SU(4), )
         }, {})
def process_last_week(cursor, now):
    current_date = now + relativedelta(weekday=rrule.SU(-2))
    start_string = current_date.strftime('%Y-%m-%d 00:00:00')
    end = current_date + timedelta(days=6)
    end_string = end.strftime('%Y-%m-%d 23:59:59')
    count = get_count(cursor, start_string, end_string)
    LOGGER.info('Active users last week (%s through %s): %s', start_string,
                end_string, count)
    return count
 def testMultipleByWeek(self):
     self.failUnlessParseMatches(
         "FREQ=MONTHLY;BYDAY=-2FR,1SU",
         False,  # we only do a single "on the nth Xday" rule in the UI
         {
             'freq': rrule.MONTHLY,
             'interval': 1,
             'byweekday': (rrule.FR(-2), rrule.SU(1))
         },
         {})
 def testFifthSunday(self):
     self.failUnlessParseMatches(
         "FREQ=MONTHLY;BYDAY=5SU",
         False,  # we don't do "fifth" in the UI
         {
             'freq': rrule.MONTHLY,
             'interval': 1,
             'byweekday': (rrule.SU(5), )
         },
         {})
Пример #5
0
    def _extra_holidays(self, year):
        # Add the superbowl, first Sunday in Feb.
        superb_owl = rrule.rrule(rrule.MONTHLY,
                                 count=1,
                                 byweekday=rrule.SU,
                                 dtstart=datetime.date(year, 2, 1))
        self.hol.append({list(superb_owl)[0]: 'Superbowl Sunday'})

        # Mother's day, Second Sunday in May
        mday = rrule.rrule(rrule.MONTHLY,
                           count=1,
                           byweekday=rrule.SU(2),
                           dtstart=datetime.date(year, 5, 1))
        self.hol.append({list(mday)[0]: "Mother's Day"})

        # Father's day, Third Sunday in June
        fday = rrule.rrule(rrule.MONTHLY,
                           count=1,
                           byweekday=rrule.SU(3),
                           dtstart=datetime.date(year, 6, 1))
        self.hol.append({list(fday)[0]: "Father's Day"})
Пример #6
0
 def end_period(self):
     return self.now + relativedelta.relativedelta(
         hour=0, minute=0, second=0, microsecond=0,
         weekday=rrule.SU(1)) + timedelta(days=1)