Show More
@@ -15,6 +15,10 b' from demandload import *' | |||||
15 | demandload(globals(), "cStringIO errno popen2 re shutil sys tempfile") |
|
15 | demandload(globals(), "cStringIO errno popen2 re shutil sys tempfile") | |
16 | demandload(globals(), "os threading time") |
|
16 | demandload(globals(), "os threading time") | |
17 |
|
17 | |||
|
18 | # used by parsedate | |||
|
19 | defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', | |||
|
20 | '%a %b %d %H:%M:%S %Y') | |||
|
21 | ||||
18 | class SignalInterrupt(Exception): |
|
22 | class SignalInterrupt(Exception): | |
19 | """Exception raised on SIGTERM and SIGHUP.""" |
|
23 | """Exception raised on SIGTERM and SIGHUP.""" | |
20 |
|
24 | |||
@@ -883,10 +887,12 b" def strdate(string, format='%a %b %d %H:" | |||||
883 | when = int(time.mktime(time.strptime(date, format))) + offset |
|
887 | when = int(time.mktime(time.strptime(date, format))) + offset | |
884 | return when, offset |
|
888 | return when, offset | |
885 |
|
889 | |||
886 | def parsedate(string, formats=('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M')): |
|
890 | def parsedate(string, formats=None): | |
887 | """parse a localized time string and return a (unixtime, offset) tuple. |
|
891 | """parse a localized time string and return a (unixtime, offset) tuple. | |
888 | The date may be a "unixtime offset" string or in one of the specified |
|
892 | The date may be a "unixtime offset" string or in one of the specified | |
889 | formats.""" |
|
893 | formats.""" | |
|
894 | if not formats: | |||
|
895 | formats = defaultdateformats | |||
890 | try: |
|
896 | try: | |
891 | when, offset = map(int, string.split(' ')) |
|
897 | when, offset = map(int, string.split(' ')) | |
892 | except ValueError: |
|
898 | except ValueError: |
General Comments 0
You need to be logged in to leave comments.
Login now