diff mercurial/util.py @ 3251:e5c9a084ffe3

util.strdate: assume local time when no timezone specified
author Jose M. Prieto <jmprieto@gmx.net>
date Tue, 03 Oct 2006 12:33:18 +0200
parents e96d2956eb4a
children c9cd63a6fce9
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -909,9 +909,15 @@ def strdate(string, format='%a %b %d %H:
         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):