Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_encode_cdfepoch():
x = cdfepoch.encode([62285326000000.0, 62985326000000.0])
assert x[0] == '1973-09-28 23:26:40.000000000'
assert x[1] == '1995-12-04 19:53:20.000000000'
def test_parse_cdfepoch():
x = cdfepoch.encode(62567898765432.0)
assert x == "1982-09-12 11:52:45.432000000"
stripped_time = x[:23]
parsed = cdfepoch.parse(stripped_time)
assert parsed[0] == approx(62567898765432.0)
def test_encode_cdfepoch16():
'''
cdf_encode_epoch16(dcomplex(63300946758.000000, 176214648000.00000)) in IDL
returns 04-Dec-2005 20:39:28.176.214.654.976
However, I believe this IDL routine is bugged. This website:
https://www.epochconverter.com/seconds-days-since-y0
shows a correct answer.
'''
x = cdfepoch.encode(np.complex128(63300946758.000000 + 176214648000.00000j))
assert x == '2005-12-04 20:19:18.176214648'
y = cdfepoch.encode(np.complex128([33300946758.000000 + 106014648000.00000j,
61234543210.000000 + 000011148000.00000j]))
assert y[0] == '1055-04-07 14:59:18.106014648'
assert y[1] == '1940-06-12 03:20:10.000011148'
def test_encode_cdftt2000():
x = cdfepoch.encode(186999622360321123)
assert x == '2005-12-04 20:20:22.360321120'
y = cdfepoch.encode([500000000100, 123456789101112131])
assert y[0] == '2000-01-01 12:08:20.000000100'
assert y[1] == '2003-11-30 09:33:09.101112128'
def test_encode_cdfepoch16():
'''
cdf_encode_epoch16(dcomplex(63300946758.000000, 176214648000.00000)) in IDL
returns 04-Dec-2005 20:39:28.176.214.654.976
However, I believe this IDL routine is bugged. This website:
https://www.epochconverter.com/seconds-days-since-y0
shows a correct answer.
'''
x = cdfepoch.encode(np.complex128(63300946758.000000 + 176214648000.00000j))
assert x == '2005-12-04 20:19:18.176214648'
y = cdfepoch.encode(np.complex128([33300946758.000000 + 106014648000.00000j,
61234543210.000000 + 000011148000.00000j]))
assert y[0] == '1055-04-07 14:59:18.106014648'
assert y[1] == '1940-06-12 03:20:10.000011148'
def test_parse_cdfepoch16():
input_time = 53467976543.0 + 543218654100j
x = cdfepoch.encode(input_time)
assert x == "1694-05-01 07:42:23.543218654"
add_precision = x + "000"
parsed = cdfepoch.parse(add_precision)
assert parsed[0] == approx(53467976543 + .543218654)
assert cdfepoch.to_datetime(input_time) == datetime(1694, 5, 1, 7, 42, 23, 543219)
def test_encode_cdftt2000():
x = cdfepoch.encode(186999622360321123)
assert x == '2005-12-04 20:20:22.360321120'
y = cdfepoch.encode([500000000100, 123456789101112131])
assert y[0] == '2000-01-01 12:08:20.000000100'
assert y[1] == '2003-11-30 09:33:09.101112128'