Skip to content

Commit

Permalink
🐛 Ensure all datetimes are truly UTC for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
hreeder committed Apr 9, 2020
1 parent a017b8b commit c40d51d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assh/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def get_instances(cache_dir):
with open(cache_path) as cache_file:
cached_response = json.load(cache_file)

cache_updated = datetime.datetime.utcfromtimestamp(
cached_response.get("fetched_at", 0)
cache_updated = datetime.datetime.fromtimestamp(
cached_response.get("fetched_at", 0), tz=datetime.timezone.utc
)
now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)

if cache_updated < (now - datetime.timedelta(minutes=1)):
instances = _get_fresh_instances()
Expand Down

0 comments on commit c40d51d

Please sign in to comment.