diff options
author | ayleph <ayleph@thisshitistemp.com> | 2015-03-10 23:55:51 -0700 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2015-03-12 16:28:14 +0100 |
commit | c975bd37406b4bd2676d080357f173c662925404 (patch) | |
tree | 79e1e4210979935abe0a8eae3aa00dc363508396 | |
parent | fc3c8f21a08a97051a709cb1a41b4339c3748ab5 (diff) | |
download | mediagoblin-c975bd37406b4bd2676d080357f173c662925404.tar.lz mediagoblin-c975bd37406b4bd2676d080357f173c662925404.tar.xz mediagoblin-c975bd37406b4bd2676d080357f173c662925404.zip |
Use UTC for all timesince comparisons
Signed-off-by: Jessica Tallon <jessica@megworld.co.uk>
-rw-r--r-- | mediagoblin/tests/test_timesince.py | 2 | ||||
-rw-r--r-- | mediagoblin/tools/timesince.py | 14 |
2 files changed, 2 insertions, 14 deletions
diff --git a/mediagoblin/tests/test_timesince.py b/mediagoblin/tests/test_timesince.py index 6579eb09..99ae31da 100644 --- a/mediagoblin/tests/test_timesince.py +++ b/mediagoblin/tests/test_timesince.py @@ -16,7 +16,7 @@ from datetime import datetime, timedelta -from mediagoblin.tools.timesince import is_aware, timesince +from mediagoblin.tools.timesince import timesince def test_timesince(): diff --git a/mediagoblin/tools/timesince.py b/mediagoblin/tools/timesince.py index b761c1be..7a8b3ff0 100644 --- a/mediagoblin/tools/timesince.py +++ b/mediagoblin/tools/timesince.py @@ -33,18 +33,6 @@ import pytz from mediagoblin.tools.translate import pass_to_ugettext, lazy_pass_to_ungettext as _ -"""UTC time zone as a tzinfo instance.""" -utc = pytz.utc if pytz else UTC() - -def is_aware(value): - """ - Determines if a given datetime.datetime is aware. - - The logic is described in Python's docs: - http://docs.python.org/library/datetime.html#datetime.tzinfo - """ - return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None - def timesince(d, now=None, reversed=False): """ Takes two datetime objects and returns the time between d and now @@ -73,7 +61,7 @@ def timesince(d, now=None, reversed=False): now = datetime.datetime(now.year, now.month, now.day) if not now: - now = datetime.datetime.now(utc if is_aware(d) else None) + now = datetime.datetime.utcnow() delta = (d - now) if reversed else (now - d) # ignore microseconds |