From cd8545c4c6f25de1e23709cdeeb39d95ed71bb12 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Mon, 17 Feb 2020 04:42:23 -0700 Subject: [PATCH] Forcing datetime to utc (#84) --- panoptes/utils/tests/test_utils.py | 3 ++- panoptes/utils/time.py | 4 +++- requirements.txt | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/panoptes/utils/tests/test_utils.py b/panoptes/utils/tests/test_utils.py index 97081dc22..3bfe9f630 100644 --- a/panoptes/utils/tests/test_utils.py +++ b/panoptes/utils/tests/test_utils.py @@ -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 @@ -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(): diff --git a/panoptes/utils/time.py b/panoptes/utils/time.py index 15a089ec8..17326c64e 100644 --- a/panoptes/utils/time.py +++ b/panoptes/utils/time.py @@ -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 @@ -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 diff --git a/requirements.txt b/requirements.txt index 8e3afdc7d..ba93288cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ numpy photutils pyserial python-dateutil -pytz PyYAML pyzmq ruamel.yaml>=0.15