Skip to content

Commit

Permalink
Fix issue where '%s' is not supported in strftime() (non unix machine)
Browse files Browse the repository at this point in the history
as the doc doesn't have it. This solution should be py2-py3 compliant.
  • Loading branch information
Kyria committed Dec 30, 2016
1 parent 50c78c3 commit eae0073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion esipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
pass


__version__ = '0.1.0'
__version__ = '0.1.1'
15 changes: 10 additions & 5 deletions esipy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from .cache import DummyCache

from collections import namedtuple
from datetime import datetime
from email.utils import parsedate
from pyswagger.core import BaseClient
from requests import Request
from requests import Session
from requests.adapters import HTTPAdapter


import six
import datetime


class EsiClient(BaseClient):
Expand Down Expand Up @@ -135,10 +136,14 @@ def request(self, req_and_resp, raw_body_only=False, opt={}):
def __cache_response(self, cache_key, res):
if 'expires' in res.headers:
# this date is ALWAYS in UTC (RFC 7231)
expire = datetime.datetime(
*parsedate(res.headers['expires'])[:6]
).strftime('%s')
now = datetime.datetime.utcnow().strftime('%s')
#
epoch = datetime(1970, 1, 1)
expire = (
datetime(
*parsedate(res.headers['expires'])[:6]
) - epoch
).total_seconds()
now = (datetime.utcnow() - epoch).total_seconds()
cache_timeout = int(expire) - int(now)

else:
Expand Down

0 comments on commit eae0073

Please sign in to comment.