def base_quarter(self): """ Get the DateRange of the quarter that contains self.bdate. """ quarter = get_quarter(self.bmonth) start, end = self.get_quarter_range(self.byear, quarter) return DateFrame(start, end)
def base_month(self): """ Get the DateRange of the month that contains self.bdate """ year, month = self.byear, self.bmonth start, end = self.get_month_range(year, month) return DateFrame(start, end)
def next_year(self, years=1): """ Get the DateRange that n years after self.bdate. Argus: year - next n years """ start, end = self.relative_year(years=years) return DateFrame(start, end)
def next_week(self, weeks=1): """ Get the DateRange that n weeks after self.bdate. Argus: weeks - next n weeks """ start, end = self.relative_week(weeks=weeks) return DateFrame(start, end)
def next_quarter(self, quarters=1): """ Get the DateRange that n quarters after self.bdate. Argus: quarters - next n quarters """ start, end = self.relative_quarter(quarters=quarters) return DateFrame(start, end)
def next_month(self, months=1): """ Get the DateRange that n months after self.bdate. Argus: months - next n months """ start, end = self.relative_month(months=months) return DateFrame(start, end)
def next_day(self, days=1): """ Get the DateRange that n days after self.bdate. Argus: days - next n days """ start, end = self.relative_day(days=days) return DateFrame(start, end)
def prev_day(self, days=1): """ Get the DateRange that n days before self.bdate. Argus: days - n days ago """ ndays = days * -1 start, end = self.relative_day(days=ndays) return DateFrame(start, end)
def prev_year(self, years=1): """ Get the DateRange that n years before self.bdate. Argus: years - n years ago """ nyears = years * -1 start, end = self.relative_year(years=nyears) return DateFrame(start, end)
def prev_quarter(self, quarters=1): """ Get the DateRange that n quarters before self.bdate. Argus: quarters - n quarters ago """ nquarters = quarters * -1 start, end = self.relative_quarter(quarters=nquarters) return DateFrame(start, end)
def prev_month(self, months=1): """ Get the DateRange that n months before self.bdate. Argus: months - n months ago """ nmonths = months * -1 start, end = self.relative_month(months=nmonths) return DateFrame(start, end)
def prev_week(self, weeks=1): """ Get the DateRange that n weeks before self.bdate. Argus: weeks - n week ago """ nweeks = weeks * -1 start, end = self.relative_week(weeks=nweeks) return DateFrame(start, end)
def to_date(self, to_date): """ Return the DateRange from self.bdate to `to_date` Argus: to_date - Example: date(2015, 1, 1) """ if to_date < self.bdate: raise InvalidDateRange() return DateFrame(self.bdate, to_date + timedelta(days=1))
def from_date(self, from_date): """ Return the DateRange from `from_date` to self.bdate Argus: from_date - Example: date(2015, 1, 1) """ if from_date > self.bdate: raise InvalidDateRange() return DateFrame(from_date, self.bdate + timedelta(days=1))
def base_day(self): """ Get the DateRange of self.bdate. """ return DateFrame(self.bdate, self.bdate)
def base_week(self): """ Get DateRange of the week that contains self.bdate. """ start, end = self.get_week_range(self.bdate) return DateFrame(start, end)
def base_year(self): """ Get the DateRange of the year that contains self.bdate. """ start, end = self.get_year_range(self.byear) return DateFrame(start, end)