Skip to content
Snippets Groups Projects
Commit 82d6a451 authored by Jeremy M Fee's avatar Jeremy M Fee
Browse files

Switch get_previous_interval precision to milliseconds to match Edge

parent c0386793
No related branches found
No related tags found
1 merge request!187Switch get_previous_interval precision to milliseconds to match Edge
......@@ -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]:
......
......@@ -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"),
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment