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

Forcing datetime to utc #84

Merged
merged 4 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion panoptes/utils/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import signal
import time
from datetime import timezone as tz
from datetime import datetime as dt
from astropy import units as u

Expand Down Expand Up @@ -86,7 +87,7 @@ def test_pretty_time():

# This will increment one second - see docs
t3 = current_time(datetime=True)
assert t3 == dt(2016, 8, 13, 10, 0, 2)
assert t3 == dt(2016, 8, 13, 10, 0, 2, tzinfo=tz.utc)


def test_countdown_timer_bad_input():
Expand Down
4 changes: 3 additions & 1 deletion panoptes/utils/time.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import time
from datetime import timezone as tz

from astropy import units as u
from astropy.time import Time

Expand Down Expand Up @@ -67,7 +69,7 @@ def current_time(flatten=False, datetime=False, pretty=False):

if datetime:
# Add UTC timezone
_time = _time.to_datetime()
_time = _time.to_datetime(timezone=tz.utc)

return _time

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ numpy
photutils
pyserial
python-dateutil
pytz
PyYAML
pyzmq
ruamel.yaml>=0.15
Expand Down