Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align_time does not round sub-second time #94

Open
gerritholl opened this issue Jun 23, 2021 · 0 comments
Open

align_time does not round sub-second time #94

gerritholl opened this issue Jun 23, 2021 · 0 comments

Comments

@gerritholl
Copy link
Contributor

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:

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:

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant