Beispiel #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)
Beispiel #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)
Beispiel #3
0
def datetime_to_timestamp(x):
    if isinstance(x, datetime):
        return timestamp(x)
    return x
Beispiel #4
0
def datetime_to_timestamp(x):
    """Convert a datetime into a utc float timestamp"""
    if isinstance(x, datetime):
        return timestamp(x)
    return x
Beispiel #5
0
def datetime_to_timestamp(x):
    if isinstance(x, datetime):
        return timestamp(x)
    return x