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(self):
x = cdflib.cdfepoch.encode([62285326000000.0, 62985326000000.0])
self.assertEqual(x[0], '1973-09-28T23:26:40.000')
self.assertEqual(x[1], '1995-12-04T19:53:20.000')
y = cdflib.cdfepoch.encode(62975326000002.0, iso_8601=False)
self.assertEqual(y, '1995-08-11 02:06:40.002')
def test_encode_cdfepoch(self):
x = cdflib.cdfepoch.encode([62285326000000.0, 62985326000000.0])
self.assertEqual(x[0], '1973-09-28T23:26:40.000')
self.assertEqual(x[1], '1995-12-04T19:53:20.000')
y = cdflib.cdfepoch.encode(62975326000002.0, iso_8601=False)
self.assertEqual(y, '1995-08-11 02:06:40.002')
def test_parse_cdfepoch(self):
x = cdflib.cdfepoch.encode(62567898765432.0)
self.assertEqual(x, "1982-09-12T11:52:45.432")
parsed = cdflib.cdfepoch.parse(x)
self.assertEqual(parsed, 62567898765432.0)
def test_encode_cdftt2000(self):
x = cdflib.cdfepoch.encode(186999622360321123)
self.assertEqual(x, '2005-12-04T20:19:18.176321123')
x1 = cdflib.cdfepoch.encode(186999622360321123, iso_8601=False)
self.assertEqual(x1, '2005-12-04 20:19:18.176.321.123')
y = cdflib.cdfepoch.encode([500000000100, 123456789101112131], iso_8601=False)
self.assertEqual(y[0], '2000-01-01 12:07:15.816.000.100')
self.assertEqual(y[1], '2003-11-30 09:32:04.917.112.131')
def test_parse_cdfepoch16(self):
input_time = np.complex(53467976543.0, 543218654100)
x = cdflib.cdfepoch.encode(input_time)
self.assertEqual(x, "1694-05-01T07:42:23.543218654100")
parsed = cdflib.cdfepoch.parse(x, to_np=True)
self.assertEqual(parsed, input_time)
def test_parse_cdftt2000(self):
input_time = 131415926535793238
x = cdflib.cdfepoch.encode(input_time)
self.assertEqual(x, "2004-03-01T12:24:22.351793238")
parsed = cdflib.cdfepoch.parse(x)
self.assertEqual(parsed, input_time)
def test_encode_cdftt2000(self):
x = cdflib.cdfepoch.encode(186999622360321123)
self.assertEqual(x, '2005-12-04T20:19:18.176321123')
x1 = cdflib.cdfepoch.encode(186999622360321123, iso_8601=False)
self.assertEqual(x1, '2005-12-04 20:19:18.176.321.123')
y = cdflib.cdfepoch.encode([500000000100, 123456789101112131], iso_8601=False)
self.assertEqual(y[0], '2000-01-01 12:07:15.816.000.100')
self.assertEqual(y[1], '2003-11-30 09:32:04.917.112.131')
def test_encode_cdfepoch16(self):
"""
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 = cdflib.cdfepoch.encode(np.complex128(63300946758.000000 + 176214648000.00000j))
self.assertEqual(x, '2005-12-04T20:19:18.176214648000')
y = cdflib.cdfepoch.encode(np.complex128([33300946758.000000 + 106014648000.00000j,
61234543210.000000 + 000011148000.00000j]), iso_8601=False)
self.assertEqual(y[0], '1055-04-07 14:59:18.106.014.648.000')
self.assertEqual(y[1], '1940-06-12 03:20:10.000.011.148.000')
def test_encode_cdftt2000(self):
x = cdflib.cdfepoch.encode(186999622360321123)
self.assertEqual(x, '2005-12-04T20:19:18.176321123')
x1 = cdflib.cdfepoch.encode(186999622360321123, iso_8601=False)
self.assertEqual(x1, '2005-12-04 20:19:18.176.321.123')
y = cdflib.cdfepoch.encode([500000000100, 123456789101112131], iso_8601=False)
self.assertEqual(y[0], '2000-01-01 12:07:15.816.000.100')
self.assertEqual(y[1], '2003-11-30 09:32:04.917.112.131')