diff --git a/src/robofish/io/file.py b/src/robofish/io/file.py index 14d2a4d1d3f2aec3253e84d6733c4ae3b6b6851a..5d5742ffd3f28d63e038178db0ab296927e6249e 100644 --- a/src/robofish/io/file.py +++ b/src/robofish/io/file.py @@ -234,10 +234,10 @@ class File(h5py.File): def format_calendar_time_point(p): if isinstance(p, datetime.datetime): assert p.tzinfo is not None, "Missing timezone for calendar point." - return p.isoformat(timespec="milliseconds") + return p.isoformat(timespec="microseconds") elif isinstance(p, str): assert p == datetime.datetime.fromisoformat(p).isoformat( - timespec="milliseconds" + timespec="microseconds" ) return p else: @@ -249,8 +249,6 @@ class File(h5py.File): format_calendar_time_point(p) for p in calendar_time_points ] - for c in calendar_time_points: - print(type(c)) sampling.create_dataset( "calendar_time_points", data=calendar_time_points, diff --git a/src/robofish/io/io.py b/src/robofish/io/io.py index c8894ca38365340509b94e59b5ea85374357109d..4c12aded73ffab9675370b160dac54b832164331 100644 --- a/src/robofish/io/io.py +++ b/src/robofish/io/io.py @@ -16,7 +16,7 @@ def now_iso8061() -> str: str: The current time as iso8061 string. """ return datetime.datetime.now(datetime.timezone.utc).isoformat( - timespec="milliseconds" + timespec="microseconds" ) diff --git a/tests/robofish/io/test_file.py b/tests/robofish/io/test_file.py index fe6f1f9c5f8dbbcb88a3a9162aaa324da3c8df2e..c098d574d2d560f0d3e2ffb4eaa28e965a9e87e0 100644 --- a/tests/robofish/io/test_file.py +++ b/tests/robofish/io/test_file.py @@ -112,7 +112,7 @@ def test_multiple_entities(): # create new sampling m_points = np.ones((timesteps)) c_points = np.empty((timesteps), dtype="O") - c_points[:5] = "2020-12-02T10:21:58.100+00:00" + c_points[:5] = "2020-12-02T10:21:58.100000+00:00" c_points[5:] = robofish.io.now_iso8061() new_sampling = sf.create_sampling( diff --git a/tests/robofish/io/test_io.py b/tests/robofish/io/test_io.py index bb4cb69365d8bc8d325fb1bf7cd502fb0be536f3..3a7bb32390223adfbd4e7f2f1f9a3454c93bdfa4 100644 --- a/tests/robofish/io/test_io.py +++ b/tests/robofish/io/test_io.py @@ -6,10 +6,10 @@ import numpy as np def test_now_iso8061(): - # Example time: 2021-01-05T14:33:40.401+00:00 + # Example time: 2021-01-05T14:33:40.401000+00:00 time = robofish.io.now_iso8061() assert type(time) == str - assert len(time) == 29 + assert len(time) == 32 def test_read_multiple_single():