예제 #1
0
def test_time_manipulation():
    round_tripped_datetime = utils.datetime_to_iso(
                                utils.from_unix_epoch_time_secs(
                                    utils.to_unix_epoch_time_secs(
                                        utils.iso_to_datetime("2014-12-10T19:09:34.000Z"))))
    print(round_tripped_datetime)
    assert "2014-12-10T19:09:34.000Z" == round_tripped_datetime, round_tripped_datetime

    round_tripped_datetime = utils.datetime_to_iso(
                                utils.from_unix_epoch_time_secs(
                                    utils.to_unix_epoch_time_secs(
                                        utils.iso_to_datetime("1969-04-28T23:48:34.123Z"))))
    print(round_tripped_datetime)
    assert "1969-04-28T23:48:34.123Z" == round_tripped_datetime, round_tripped_datetime

    ## check that rounding to milliseconds works
    round_tripped_datetime = utils.datetime_to_iso(
                                utils.from_unix_epoch_time_secs(
                                    utils.to_unix_epoch_time_secs(
                                        utils.iso_to_datetime("1969-04-28T23:48:34.999499Z"))))
    print(round_tripped_datetime)
    assert "1969-04-28T23:48:34.999Z" == round_tripped_datetime, round_tripped_datetime

    ## check that rounding to milliseconds works
    round_tripped_datetime = utils.datetime_to_iso(
                                utils.from_unix_epoch_time_secs(
                                    utils.to_unix_epoch_time_secs(
                                        utils.iso_to_datetime("1969-04-27T23:59:59.999999Z"))))
    print(round_tripped_datetime)
    assert "1969-04-28T00:00:00.000Z" == round_tripped_datetime, round_tripped_datetime
예제 #2
0
def test_time_manipulation():
    round_tripped_datetime = utils.datetime_to_iso(
        utils.from_unix_epoch_time_secs(
            utils.to_unix_epoch_time_secs(
                utils.iso_to_datetime("2014-12-10T19:09:34.000Z"))))
    assert_equals("2014-12-10T19:09:34.000Z", round_tripped_datetime)

    round_tripped_datetime = utils.datetime_to_iso(
        utils.from_unix_epoch_time_secs(
            utils.to_unix_epoch_time_secs(
                utils.iso_to_datetime("1969-04-28T23:48:34.123Z"))))
    assert_equals("1969-04-28T23:48:34.123Z", round_tripped_datetime)

    # check that rounding to milliseconds works
    round_tripped_datetime = utils.datetime_to_iso(
        utils.from_unix_epoch_time_secs(
            utils.to_unix_epoch_time_secs(
                utils.iso_to_datetime("1969-04-28T23:48:34.999499Z"))))
    assert_equals("1969-04-28T23:48:34.999Z", round_tripped_datetime)

    # check that rounding to milliseconds works
    round_tripped_datetime = utils.datetime_to_iso(
        utils.from_unix_epoch_time_secs(
            utils.to_unix_epoch_time_secs(
                utils.iso_to_datetime("1969-04-27T23:59:59.999999Z"))))
    assert_equals("1969-04-28T00:00:00.000Z", round_tripped_datetime)
예제 #3
0
def epoch_time_to_iso(epoch_time):
    """
    Convert seconds since unix epoch to a string in ISO format
    """
    return None if epoch_time is None else utils.datetime_to_iso(utils.from_unix_epoch_time_secs(epoch_time))