Skip to content

Commit

Permalink
Covering authenticator.py, pylover#182
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jun 5, 2019
1 parent 3a57a3c commit d815f3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions restfulpy/datetimehelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ def parse_time(value) -> date:
and future exceptions handling.
"""


if isinstance(value, float):
return datetime.fromtimestamp(value).time()
return datetime.utcfromtimestamp(value).time()

# Parse and return if value is unix timestamp
if POSIX_TIME_PATTERN.match(value):
value = float(value)
return datetime.fromtimestamp(value).time()
return datetime.utcfromtimestamp(value).time()

return dateutil_parse(value).time()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def test_local_datetime(self):
assert now.utcoffset() == timedelta(0, 10800)

def test_parse_time_posix_timestamp(self):
assert parse_time(1000000.11) == time(17, 16, 40, 110000)
assert parse_time('1000000.11') == time(17, 16, 40, 110000)
assert parse_time(1000000.11) == time(13, 46, 40, 110000)
assert parse_time('1000000.11') == time(13, 46, 40, 110000)

def test_localtimezone(self):
assert localtimezone() is not None
Expand Down

0 comments on commit d815f3c

Please sign in to comment.