code: def quarter(dt):
      
      quarters = rrule.rrule(
         rrule.MONTHLY,
         bymonth = (1, 4, 7, 10),
         bysetpos = -1,
         dtstart = datetime(dt.year, 1, 1),
         count = 8
      )
      first_day = quarters.before(dt, True)
      last_day = quarters.after(dt) - relativedelta.relativedelta(days=1)
      return (first_day, last_day)
docs: Return start/stop datetime for the quarter as defined by dt.