示例#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')
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)