diff options
author | Yaroslav Halchenko <debian@onerussian.com> | 2014-12-18 12:39:13 -0500 |
---|---|---|
committer | Yaroslav Halchenko <debian@onerussian.com> | 2014-12-18 12:39:13 -0500 |
commit | 4a47a9c8d8253d0ae2a233fa8599b1a1c54ec53f (patch) | |
tree | 3a83e21fdc49a6111ab7a67b131c602990c277be | |
parent | 891b124f5cc6bfd242b217759f362878b596f6e2 (diff) | |
download | gitpython-4a47a9c8d8253d0ae2a233fa8599b1a1c54ec53f.tar.gz |
BF: adjust mktime output for the local offset (Close #218)
-rw-r--r-- | git/objects/util.py | 5 | ||||
-rw-r--r-- | git/test/test_util.py | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/git/objects/util.py b/git/objects/util.py index f36bf296..d31c4c93 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -156,7 +156,10 @@ def parse_date(string_date): fstruct = time.struct_time((dtstruct.tm_year, dtstruct.tm_mon, dtstruct.tm_mday, tstruct.tm_hour, tstruct.tm_min, tstruct.tm_sec, dtstruct.tm_wday, dtstruct.tm_yday, tstruct.tm_isdst)) - return int(time.mktime(fstruct)), utctz_to_altz(offset) + utctime = time.mktime(fstruct) + # time.mktime returns local time, so we need to adjust it for local offset + utctime -= time.altzone if time.daylight else time.timezone + return int(utctime), utctz_to_altz(offset) except ValueError: continue # END exception handling diff --git a/git/test/test_util.py b/git/test/test_util.py index d8682030..10d397c3 100644 --- a/git/test/test_util.py +++ b/git/test/test_util.py @@ -102,7 +102,7 @@ class TestUtils(TestBase): iso3 = ("2005.04.07 22:13:11 -0000", 0) alt = ("04/07/2005 22:13:11", 0) alt2 = ("07.04.2005 22:13:11", 0) - veri_time = 1112904791 # the time this represents + veri_time = 1112911991 # the time this represents for date, offset in (rfc, iso, iso2, iso3, alt, alt2): assert_rval(parse_date(date), veri_time, offset) # END for each date type |