##// 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 tz = int(tz)
909 tz = int(tz)
910 offset = - 3600 * (tz / 100) - 60 * (tz % 100)
910 offset = - 3600 * (tz / 100) - 60 * (tz % 100)
911 else:
911 else:
912 date, offset = string, 0
912 date, offset = string, None
913 localunixtime = int(calendar.timegm(time.strptime(date, format)))
913 timetuple = time.strptime(date, format)
914 unixtime = localunixtime + offset
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 return unixtime, offset
921 return unixtime, offset
916
922
917 def parsedate(string, formats=None):
923 def parsedate(string, formats=None):
@@ -21,13 +21,13 b' export TZ'
21 # PST=UTC-8 / PDT=UTC-7
21 # PST=UTC-8 / PDT=UTC-7
22 hg debugrebuildstate
22 hg debugrebuildstate
23 echo "a" > a
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 hg debugrebuildstate
25 hg debugrebuildstate
26 echo "b" > a
26 echo "b" > a
27 hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5"
27 hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5"
28 hg debugrebuildstate
28 hg debugrebuildstate
29 echo "c" > a
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 hg debugrebuildstate
31 hg debugrebuildstate
32 echo "d" > a
32 echo "d" > a
33 hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5"
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 transaction abort!
13 transaction abort!
14 rollback completed
14 rollback completed
15 Sun Jan 15 13:30:00 2006 +0500
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 Sat Jul 15 13:30:00 2006 +0500
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 Sun Jun 11 00:26:40 2006 -0400
19 Sun Jun 11 00:26:40 2006 -0400
20 Sat Apr 15 13:30:00 2006 +0200
20 Sat Apr 15 13:30:00 2006 +0200
21 Sat Apr 15 13:30:00 2006 +0000
21 Sat Apr 15 13:30:00 2006 +0000
General Comments 0
You need to be logged in to leave comments. Login now