Skip to content

Commit

Permalink
Forcing datetime to utc (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee authored Feb 17, 2020
1 parent 9e642c2 commit cd8545c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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 @@ -96,7 +97,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

0 comments on commit cd8545c

Please sign in to comment.