##// END OF EJS Templates
util.strdate: assume local time when no timezone specified
Jose M. Prieto -
r3256:e5c9a084 default
parent child Browse files
Show More
@@ -909,9 +909,15 b" def strdate(string, format='%a %b %d %H:"
909 909 tz = int(tz)
910 910 offset = - 3600 * (tz / 100) - 60 * (tz % 100)
911 911 else:
912 date, offset = string, 0
913 localunixtime = int(calendar.timegm(time.strptime(date, format)))
914 unixtime = localunixtime + offset
912 date, offset = string, None
913 timetuple = time.strptime(date, format)
914 localunixtime = int(calendar.timegm(timetuple))
915 if offset is None:
916 # local timezone
917 unixtime = int(time.mktime(timetuple))
918 offset = unixtime - localunixtime
919 else:
920 unixtime = localunixtime + offset
915 921 return unixtime, offset
916 922
917 923 def parsedate(string, formats=None):
@@ -21,13 +21,13 b' export TZ'
21 21 # PST=UTC-8 / PDT=UTC-7
22 22 hg debugrebuildstate
23 23 echo "a" > a
24 hg ci -d "2006-07-15 13:30" -m "summer@UTC"
24 hg ci -d "2006-07-15 13:30" -m "summer@UTC-7"
25 25 hg debugrebuildstate
26 26 echo "b" > a
27 27 hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5"
28 28 hg debugrebuildstate
29 29 echo "c" > a
30 hg ci -d "2006-01-15 13:30" -m "winter@UTC"
30 hg ci -d "2006-01-15 13:30" -m "winter@UTC-8"
31 31 hg debugrebuildstate
32 32 echo "d" > a
33 33 hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5"
@@ -13,9 +13,9 b' abort: impossible time zone offset: 1400'
13 13 transaction abort!
14 14 rollback completed
15 15 Sun Jan 15 13:30:00 2006 +0500
16 Sun Jan 15 13:30:00 2006 +0000
16 Sun Jan 15 13:30:00 2006 -0800
17 17 Sat Jul 15 13:30:00 2006 +0500
18 Sat Jul 15 13:30:00 2006 +0000
18 Sat Jul 15 13:30:00 2006 -0700
19 19 Sun Jun 11 00:26:40 2006 -0400
20 20 Sat Apr 15 13:30:00 2006 +0200
21 21 Sat Apr 15 13:30:00 2006 +0000
General Comments 0
You need to be logged in to leave comments. Login now