diff --git a/mercurial/util.py b/mercurial/util.py index e96d2956eb4adda44bb6a0bd51d08a4873cb7e1d_bWVyY3VyaWFsL3V0aWwucHk=..e5c9a084ffe3607b01052d59a11c03f16508eed0_bWVyY3VyaWFsL3V0aWwucHk= 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -909,9 +909,15 @@ tz = int(tz) offset = - 3600 * (tz / 100) - 60 * (tz % 100) else: - date, offset = string, 0 - localunixtime = int(calendar.timegm(time.strptime(date, format))) - unixtime = localunixtime + offset + date, offset = string, None + timetuple = time.strptime(date, format) + localunixtime = int(calendar.timegm(timetuple)) + if offset is None: + # local timezone + unixtime = int(time.mktime(timetuple)) + offset = unixtime - localunixtime + else: + unixtime = localunixtime + offset return unixtime, offset def parsedate(string, formats=None): diff --git a/tests/test-parse-date b/tests/test-parse-date index e96d2956eb4adda44bb6a0bd51d08a4873cb7e1d_dGVzdHMvdGVzdC1wYXJzZS1kYXRl..e5c9a084ffe3607b01052d59a11c03f16508eed0_dGVzdHMvdGVzdC1wYXJzZS1kYXRl 100755 --- a/tests/test-parse-date +++ b/tests/test-parse-date @@ -21,9 +21,9 @@ # PST=UTC-8 / PDT=UTC-7 hg debugrebuildstate echo "a" > a -hg ci -d "2006-07-15 13:30" -m "summer@UTC" +hg ci -d "2006-07-15 13:30" -m "summer@UTC-7" hg debugrebuildstate echo "b" > a hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5" hg debugrebuildstate echo "c" > a @@ -25,9 +25,9 @@ hg debugrebuildstate echo "b" > a hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5" hg debugrebuildstate echo "c" > a -hg ci -d "2006-01-15 13:30" -m "winter@UTC" +hg ci -d "2006-01-15 13:30" -m "winter@UTC-8" hg debugrebuildstate echo "d" > a hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5" diff --git a/tests/test-parse-date.out b/tests/test-parse-date.out index e96d2956eb4adda44bb6a0bd51d08a4873cb7e1d_dGVzdHMvdGVzdC1wYXJzZS1kYXRlLm91dA==..e5c9a084ffe3607b01052d59a11c03f16508eed0_dGVzdHMvdGVzdC1wYXJzZS1kYXRlLm91dA== 100644 --- a/tests/test-parse-date.out +++ b/tests/test-parse-date.out @@ -13,5 +13,5 @@ transaction abort! rollback completed Sun Jan 15 13:30:00 2006 +0500 -Sun Jan 15 13:30:00 2006 +0000 +Sun Jan 15 13:30:00 2006 -0800 Sat Jul 15 13:30:00 2006 +0500 @@ -17,5 +17,5 @@ Sat Jul 15 13:30:00 2006 +0500 -Sat Jul 15 13:30:00 2006 +0000 +Sat Jul 15 13:30:00 2006 -0700 Sun Jun 11 00:26:40 2006 -0400 Sat Apr 15 13:30:00 2006 +0200 Sat Apr 15 13:30:00 2006 +0000