def get_past_days(num): utc = pytz.utc stash_tz = dates.get_timezone() d = datetime.now().replace(tzinfo=utc) dn = stash_tz.normalize(d).replace(hour=0, minute=0, second=0, microsecond=0) dn = dn.astimezone(utc).replace(tzinfo=None) logging.info(dn) ds = [] for i in range(1, num+1): ds.append(dn - timedelta(days=i)) return ds
def last_six_days(self): """ Fetch the last five days of events. A day is represented by a dictionary with the image of the highest severity event and a Date object for that day. If the severity is greater than a normal event, an "information" flag is set to True. Returns: A list of dictionaries. One dictionary for each of the last five days. """ utc = pytz.utc stash_tz = dates.get_timezone() d = datetime.now().replace(tzinfo=utc) dn = stash_tz.normalize(d).replace(hour=0, minute=0, second=0, microsecond=0) dn += timedelta(days=1) dn = dn.astimezone(utc).replace(tzinfo=None) logging.info(dn) calendar = self.calendar(dn, 6) return calendar