Open gerritholl opened 3 years ago
The function pytroll_collectors.helper_functions.align_time is supposed to round times. However, if there is a subsecond timestamp present, this one gets kept and the time is not rounded.
pytroll_collectors.helper_functions.align_time
This script:
from datetime import datetime, timedelta from pytroll_collectors.helper_functions import align_time t = datetime(2015, 10, 21, 22, 29, 0, 12345) t2 = align_time(t, timedelta(minutes=5)) print(t2) assert t2 == datetime(2015, 10, 21, 22, 25, 0, 0)
results in an AssertionError:
AssertionError
2015-10-21 22:25:00.012345 Traceback (most recent call last): File "/home/gholl/checkouts/protocode/mwe/bad-align.py", line 7, in <module> assert t2 == datetime(2015, 10, 21, 22, 25, 0, 0) AssertionError
because the result of align_time is datetime(2015, 10, 21, 22, 25, 0, 12345) rather than datetime(2015, 10, 21, 22, 25, 0, 0).
align_time
datetime(2015, 10, 21, 22, 25, 0, 12345)
datetime(2015, 10, 21, 22, 25, 0, 0)
The function
pytroll_collectors.helper_functions.align_time
is supposed to round times. However, if there is a subsecond timestamp present, this one gets kept and the time is not rounded.This script:
results in an
AssertionError
:because the result of
align_time
isdatetime(2015, 10, 21, 22, 25, 0, 12345)
rather thandatetime(2015, 10, 21, 22, 25, 0, 0)
.