예제 #1
0
파일: site.py 프로젝트: shockoe/stashboard
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
예제 #2
0
    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