def _monthly(self):
     num = self.num
     start = self.event.l_start_date
     year = self.now.year
     month = self.now.month
     day = self.event.l_start_date.day
     if self.event.l_start_date > self.now:  # event starts in the future
         year = self.event.l_start_date.year
         month = self.event.l_start_date.month
     while num:
         try:
             start = start.replace(year=year, month=month)
             if self.now > start:  # if event already happened
                 month, year = inc_month(month, year)
                 continue
             # change to date() so we can compare to event.end_repeat
             start_ = date(year, month, day)
         # value error most likely means that the event's start date doesn't
         # appear this calendar month
         except ValueError:
             month, year = inc_month(month, year)
             continue
         if self.we_should_stop(start, start_):
             return
         self.events.append((start, self.event))
         month, year = inc_month(month, year)
         num -= 1
Пример #2
0
 def _monthly(self):
     num = self.num
     start = self.event.l_start_date
     year = self.now.year
     month = self.now.month
     day = self.event.l_start_date.day
     if self.event.l_start_date > self.now:  # event starts in the future
         year = self.event.l_start_date.year
         month = self.event.l_start_date.month
     while num:
         try:
             start = start.replace(year=year, month=month)
             if self.now > start:  # if event already happened
                 month, year = inc_month(month, year)
                 continue
             # change to date() so we can compare to event.end_repeat
             start_ = date(year, month, day)
         # value error most likely means that the event's start date doesn't
         # appear this calendar month
         except ValueError:
             month, year = inc_month(month, year)
             continue
         if self.we_should_stop(start, start_):
             return
         self.events.append((start, self.event))
         month, year = inc_month(month, year)
         num -= 1
Пример #3
0
 def _monthly(self):
     num = self.num
     year = self.now.year
     month = self.now.month
     if self.event.l_start_date > self.now:  # event starts in the future
         year = self.event.l_start_date.year
         month = self.event.l_start_date.month
     elif self.now.day > self.event.l_start_date.day:  # event has passed
         month, year = inc_month(month, year)
     day = self.event.l_start_date.day
     while num:
         try:
             start = make_aware(
                 datetime(year, month, day), get_default_timezone()
             )
             # change to date() so we can compare to event.end_repeat
             start_ = date(year, month, day)
         # value error most likely means that the event's start date doesn't
         # appear this calendar month
         except ValueError:
             month, year = inc_month(month, year)
             continue
         if self.we_should_stop(start, start_):
             return
         self.events.append((start, self.event))
         month, year = inc_month(month, year)
         num -= 1
Пример #4
0
 def test_increment_month(self):
     month, year = inc_month(4, 2014)
     self.assertEqual(month, 5)
     self.assertEqual(year, 2014)
Пример #5
0
 def test_increment_month_and_year(self):
     month, year = inc_month(12, 2014)
     self.assertEqual(month, 1)
     self.assertEqual(year, 2015)