Esempio n. 1
0
def test_utc_timestamping():
    assert timestamp(datetime(2017, 7, 14, 2,
                              40).replace(tzinfo=utc)) == 1500000000

    for d in (datetime.now(), datetime.utcnow(), datetime(
            1999, 12, 31, 23, 59, 59), datetime(2000, 1, 1, 0, 0, 0)):
        assert datetime.utcfromtimestamp(timestamp(d)
                                         ) - d < timedelta(microseconds=10)
Esempio n. 2
0
def test_utc_timestamping():
    assert timestamp(datetime(2017, 7, 14, 2,
                              40).replace(tzinfo=utc)) == 1500000000

    for d in (datetime.now(), datetime.utcnow(),
              datetime(1999, 12, 31, 23, 59,
                       59), datetime(2000, 1, 1, 0, 0, 0)):
        assert datetime.utcfromtimestamp(timestamp(d)) - d < timedelta(
            microseconds=10)
Esempio n. 3
0
def datetime_to_timestamp(x):
    if isinstance(x, datetime):
        return timestamp(x)
    return x
Esempio n. 4
0
File: time.py Progetto: sattel/pygal
def datetime_to_timestamp(x):
    """Convert a datetime into a utc float timestamp"""
    if isinstance(x, datetime):
        return timestamp(x)
    return x
Esempio n. 5
0
def datetime_to_timestamp(x):
    if isinstance(x, datetime):
        return timestamp(x)
    return x