summaryrefslogtreecommitdiff
path: root/git/objects/util.py
diff options
context:
space:
mode:
authorishepard <spadini.davide@gmail.com>2018-04-04 10:04:23 +0200
committerSebastian Thiel <byronimo@gmail.com>2018-04-04 10:15:48 +0200
commitc6e0a6cb5c70efd0899f620f83eeebcc464be05c (patch)
treed8fc4f051490ac5a889c0ac51d2f2069b8ec924c /git/objects/util.py
parent0857d33852b6b2f4d7bc470b4c97502c7f978180 (diff)
downloadgitpython-c6e0a6cb5c70efd0899f620f83eeebcc464be05c.tar.gz
Avoid from_timestamp() function to raise an exception when the offset is greater or lower than 24 hours.
Add tests that exercise the new behaviour
Diffstat (limited to 'git/objects/util.py')
-rw-r--r--git/objects/util.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/git/objects/util.py b/git/objects/util.py
index f630f966..7b6a2763 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -121,8 +121,11 @@ utc = tzoffset(0, 'UTC')
def from_timestamp(timestamp, tz_offset):
"""Converts a timestamp + tz_offset into an aware datetime instance."""
utc_dt = datetime.fromtimestamp(timestamp, utc)
- local_dt = utc_dt.astimezone(tzoffset(tz_offset))
- return local_dt
+ try:
+ local_dt = utc_dt.astimezone(tzoffset(tz_offset))
+ return local_dt
+ except ValueError:
+ return utc_dt
def parse_date(string_date):