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