def __init__(self, ahead_months): end = compute_ahead_months(ahead_months) end_plus_one = end + ONE_DAY start = end_plus_one.replace(year=end_plus_one.year - 1) if start.day != 1: start = inc_date(start, RepeatType.Monthly, 1).replace(day=1) DateRange.__init__(self, start, end) self.ahead_months = ahead_months
def __init__(self, ahead_months): end = compute_ahead_months(ahead_months) end_plus_one = end + ONE_DAY start = end_plus_one.replace(year=end_plus_one.year-1) if start.day != 1: start = inc_date(start, RepeatType.Monthly, 1).replace(day=1) DateRange.__init__(self, start, end) self.ahead_months = ahead_months
def __init__(self, seed, year_start_month=1): assert 1 <= year_start_month <= 12 if isinstance(seed, DateRange): seed = seed.start year = seed.year if seed.month < year_start_month: year -= 1 start = date(year, year_start_month, 1) end = inc_date(start, RepeatType.Yearly, 1) - ONE_DAY DateRange.__init__(self, start, end)
def prev(self): start = inc_date(self.start, RepeatType.Yearly, -1) end = inc_date(self.end, RepeatType.Yearly, -1) return DateRange(start, end)
def prev(self): return YearRange(inc_date(self.start, RepeatType.Yearly, -1), year_start_month=self.start.month)