diff --git a/geomagio/Controller.py b/geomagio/Controller.py index 458e74e43c7b72525ab4a996949837260068109a..70af14041ab4a2862515b39c75a5f58da80af8ff 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -653,11 +653,11 @@ def get_previous_interval( Returns ------- Previous interval of approximately the same size. - Interval is rounded to nearest second, and ends one microsecond earlier. + Interval is rounded to nearest second, and ends one millisecond earlier. """ # round to nearest second to recover removed microsecond from repeated calls interval_size = round(end - start) - return (start - interval_size, start - 1e-6) + return (start - interval_size, start - 1e-3) def get_realtime_interval(interval_seconds: int) -> Tuple[UTCDateTime, UTCDateTime]: diff --git a/test/Controller_test.py b/test/Controller_test.py index 9acab443707206462f07ff38c9d7e14efd285dbd..bff8a8fdb44e354403f9940d8e07974f9b2369d0 100644 --- a/test/Controller_test.py +++ b/test/Controller_test.py @@ -301,12 +301,12 @@ def test_get_previous_interval(): previous = get_previous_interval(start=start, end=end) assert previous == ( UTCDateTime("2022-01-04T23:00:00"), - UTCDateTime("2022-01-04T23:59:59.999999Z"), + UTCDateTime("2022-01-04T23:59:59.999Z"), ) # previous interval still starts at beginning of previous hour - # even though interval is one microsecond smaller + # even though interval is one millisecond smaller previous = get_previous_interval(*previous) assert previous == ( UTCDateTime("2022-01-04T22:00:00"), - UTCDateTime("2022-01-04T22:59:59.999999Z"), + UTCDateTime("2022-01-04T22:59:59.999Z"), )