def get_period(date1, date2): list_d = [date1] current_date = date1 while date.date_compare(*current_date + date2) == 1: current_date = date.date_shift(*current_date + (1,)) list_d.append(current_date) return list_d
def diapason(self, dates1, dates2): ''' создание списка дат ''' self.dates_list = dates1 current_date = dates1[0] while date.date_compare(*current_date + dates2[0]) == 1: current_date = date.date_shift(*current_date + (1,)) self.dates_list.append(current_date)
def test_date_shift(self, date_before, delta, date_after): ''' тестируем смещение даты ''' date_shift = date.date_shift(*date_before.split('.') + [delta]) date_shift_str = '.'.join(map(str, date_shift)) message = "после смещения даты {0} на {1} дней, " +\ "должно получится {2}, a получилось {3}".\ format(date_before, delta, date_after, date_shift_str) self.assertEquals(date_shift_str, date_after, message)
def generatelist(self): ''' создание списка дат ''' blas, formula = BlasFormula.explain(self.formula) formula_obj = formula_factory(formula, self.year) formula_obj.generatelist() if len(formula_obj.dates_list) != 1: raise FormulaException('Дата не должны быть списком') date_begin = formula_obj.dates_list[0] self.dates_list = [date.date_shift(*date_begin + (blas,))]