Show More
@@ -15,7 +15,7 b' platform-specific details from the core.' | |||||
15 | from i18n import gettext as _ |
|
15 | from i18n import gettext as _ | |
16 | from demandload import * |
|
16 | from demandload import * | |
17 | demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") |
|
17 | demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") | |
18 | demandload(globals(), "os threading time") |
|
18 | demandload(globals(), "os threading time calendar") | |
19 |
|
19 | |||
20 | # used by parsedate |
|
20 | # used by parsedate | |
21 | defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', |
|
21 | defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', | |
@@ -903,14 +903,16 b" def strdate(string, format='%a %b %d %H:" | |||||
903 | (string[-5] == '+' or string[-5] == '-') and |
|
903 | (string[-5] == '+' or string[-5] == '-') and | |
904 | string[-6].isspace()) |
|
904 | string[-6].isspace()) | |
905 |
|
905 | |||
|
906 | # NOTE: unixtime = localunixtime + offset | |||
906 | if hastimezone(string): |
|
907 | if hastimezone(string): | |
907 | date, tz = string[:-6], string[-5:] |
|
908 | date, tz = string[:-6], string[-5:] | |
908 | tz = int(tz) |
|
909 | tz = int(tz) | |
909 | offset = - 3600 * (tz / 100) - 60 * (tz % 100) |
|
910 | offset = - 3600 * (tz / 100) - 60 * (tz % 100) | |
910 | else: |
|
911 | else: | |
911 | date, offset = string, 0 |
|
912 | date, offset = string, 0 | |
912 |
|
|
913 | localunixtime = int(calendar.timegm(time.strptime(date, format))) | |
913 | return when, offset |
|
914 | unixtime = localunixtime + offset | |
|
915 | return unixtime, offset | |||
914 |
|
916 | |||
915 | def parsedate(string, formats=None): |
|
917 | def parsedate(string, formats=None): | |
916 | """parse a localized time string and return a (unixtime, offset) tuple. |
|
918 | """parse a localized time string and return a (unixtime, offset) tuple. |
@@ -1,5 +1,6 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
|
3 | # This runs with TZ="GMT" | |||
3 | hg init |
|
4 | hg init | |
4 | echo "test-parse-date" > a |
|
5 | echo "test-parse-date" > a | |
5 | hg add a |
|
6 | hg add a | |
@@ -13,4 +14,21 b' echo "fail" >> a' | |||||
13 | hg ci -d "should fail" -m "fail" |
|
14 | hg ci -d "should fail" -m "fail" | |
14 | hg ci -d "100000000000000000 1400" -m "fail" |
|
15 | hg ci -d "100000000000000000 1400" -m "fail" | |
15 | hg ci -d "100000 1400000" -m "fail" |
|
16 | hg ci -d "100000 1400000" -m "fail" | |
|
17 | ||||
|
18 | # Check with local timezone other than GMT and with DST | |||
|
19 | TZ="PST+8PDT" | |||
|
20 | export TZ | |||
|
21 | # PST=UTC-8 / PDT=UTC-7 | |||
|
22 | hg debugrebuildstate | |||
|
23 | echo "a" > a | |||
|
24 | hg ci -d "2006-07-15 13:30" -m "summer@UTC" | |||
|
25 | hg debugrebuildstate | |||
|
26 | echo "b" > a | |||
|
27 | hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5" | |||
|
28 | hg debugrebuildstate | |||
|
29 | echo "c" > a | |||
|
30 | hg ci -d "2006-01-15 13:30" -m "winter@UTC" | |||
|
31 | hg debugrebuildstate | |||
|
32 | echo "d" > a | |||
|
33 | hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5" | |||
16 | hg log --template '{date|date}\n' |
|
34 | hg log --template '{date|date}\n' |
@@ -12,6 +12,10 b' rollback completed' | |||||
12 | abort: impossible time zone offset: 1400000 |
|
12 | abort: impossible time zone offset: 1400000 | |
13 | transaction abort! |
|
13 | transaction abort! | |
14 | rollback completed |
|
14 | rollback completed | |
|
15 | Sun Jan 15 13:30:00 2006 +0500 | |||
|
16 | Sun Jan 15 13:30:00 2006 +0000 | |||
|
17 | Sat Jul 15 13:30:00 2006 +0500 | |||
|
18 | Sat Jul 15 13:30:00 2006 +0000 | |||
15 | Sun Jun 11 00:26:40 2006 -0400 |
|
19 | Sun Jun 11 00:26:40 2006 -0400 | |
16 | Sat Apr 15 13:30:00 2006 +0200 |
|
20 | Sat Apr 15 13:30:00 2006 +0200 | |
17 | 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