unify date strings/remove excess parts before parsing
This commit is contained in:
parent
7def5b9e43
commit
f29132406a
1 changed files with 4 additions and 3 deletions
|
@ -51,13 +51,14 @@ def formatTimeStamp(ts, useGM=False, format='%Y-%m-%d %H:%M'):
|
||||||
|
|
||||||
|
|
||||||
def str2timeStamp(s):
|
def str2timeStamp(s):
|
||||||
|
s = s.replace('T', ' ')
|
||||||
try:
|
try:
|
||||||
t = time.strptime(s, '%Y-%m-%d %H:%M:%S')
|
t = time.strptime(s[:19], '%Y-%m-%d %H:%M:%S')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
t = time.strptime(s, '%Y-%m-%d %H:%M')
|
t = time.strptime(s[:16], '%Y-%m-%d %H:%M')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
t = time.strptime(s, '%Y-%m-%d')
|
t = time.strptime(s[:10], '%Y-%m-%d')
|
||||||
return int(time.mktime(t))
|
return int(time.mktime(t))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue