Finally resolve date parsing and text issues

select-best-date
Mike Benowitz 2019-08-07 13:34:35 -04:00
parent 5a81f5e12f
commit 335080583f
1 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import base64
from datetime import datetime
from dateutil import parser
from github import Github
import lccnorm
from lxml import etree
@ -431,5 +432,13 @@ class CCEFile():
@staticmethod
def fetchDateValue(date, text=False):
x = 1 if text else 0
return date[0][x] if len(date) > 0 else None
if len(date) > 0:
if text is False:
try:
return parser.parse(date[0][0])
except (ValueError, TypeError):
pass
else:
return date[0][1]
return None