handle dd/mm/yyyy and yyyy-mm-dd dates in text
This commit is contained in:
parent
3b84de383c
commit
3b4e56c4e0
1 changed files with 12 additions and 0 deletions
|
@ -74,6 +74,18 @@ for label in labels:
|
|||
created = re.search('^Date: (.+?)\n', str(item['body']), flags=re.MULTILINE)
|
||||
if created is not None:
|
||||
created = created.group(1).strip()
|
||||
try:
|
||||
created = datetime.strptime(created, "%d/%m/%Y")
|
||||
created = created.strftime('%Y-%m-%d')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
created = datetime.strptime(created, "%Y-%m-%d")
|
||||
created = created.strftime('%Y-%m-%d')
|
||||
except:
|
||||
pass
|
||||
|
||||
else :
|
||||
created = datetime.strptime(item['created_at'], "%Y-%m-%dT%XZ")
|
||||
created = created.strftime('%Y-%m-%d')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue