def test_months_between(self): start = datetime.date(2012, 11, 1) end = datetime.date(2013, 5, 1) result = idate.months_between(start, end) self.assertEqual(result, [11, 12, 1, 2, 3, 4, 5])
def action(self): date = self.request.GET.get("date") if date: date = datetime.datetime.strptime(date, "%d.%m.%Y") else: date = datetime.date.today() self.start, self.end = self._period(date) self.months = idate.months_between(self.start, self.end) self._send_email() return Response("ok")
def test_months_between(self): start = datetime.date(2012, 11, 1) end = datetime.date(2013, 5, 1) result = idate.months_between(start, end) self.assertEqual( result, [11, 12, 1, 2, 3, 4, 5] )
def action(self): date = self.request.GET.get('date') if date: date = datetime.datetime.strptime(date, '%d.%m.%Y') else: date = datetime.date.today() self.start, self.end = self._period(date) self.months = idate.months_between(self.start, self.end) self._send_email() return Response('ok')
def necessary_data(self, start, end): curr_year = start.year days = (end - start).days date_range = idate.xdate_range(start, end, group_by_month=True) month_range = idate.months_between(start, end) month_names = locale.months['format']['wide'].items() months = [(month_names[m - 1][1], monthrange(curr_year, m)[1], m) for m in month_range] return days, date_range, months
def necessary_data(self, start, end): curr_year = start.year days = (end - start).days date_range = idate.xdate_range(start, end, group_by_month=True) month_range = idate.months_between(start, end) month_names = locale.months['format']['wide'].items() months = [ (month_names[m-1][1], monthrange(curr_year, m)[1], m) for m in month_range ] return days, date_range, months