예제 #1
0
def test_utc():
    utc = UTC()
    assert utc.tzname(None) == 'UTC'
    assert utc.utcoffset(None) == datetime.timedelta(0)
    assert utc.dst(None) == datetime.timedelta(0)
    assert repr(utc) == str('<UTC>')
    assert str(utc) == str('UTC')
예제 #2
0
def _iter_dates(days_number, reverse=False):
    """Return a list of datetime pairs AB, BC, CD, ... that represent the
       24hs time ranges of today (until this midnight) and the
       previous days.
    """
    one_day = timedelta(days=1)
    today = datetime.utcnow().replace(hour=0, minute=0, second=0,
                                      microsecond=0, tzinfo=UTC())
    days_list = list(today + one_day * (1 - i) for i in range(days_number + 1))
    if reverse:
        days_list.reverse()
        return zip(days_list, days_list[1:])
    return zip(days_list[1:], days_list)
예제 #3
0
파일: app.py 프로젝트: redref/puppetboard
def get_node_unreported_time():
    return (datetime.datetime.utcnow() -
            timedelta(hours=app.config['UNRESPONSIVE_HOURS'])).replace(
                microsecond=0, tzinfo=UTC())
예제 #4
0
def test_utc():
    utc = UTC()
    assert utc.tzname(None) == 'UTC'
    assert utc.utcoffset(None) == datetime.timedelta(0)
    assert utc.dst(None) == datetime.timedelta(0)