fix parse date

This commit is contained in:
j 2008-10-04 17:17:13 +02:00
parent 0b9d6faaf6
commit 7f411e0b6a

View file

@ -372,12 +372,17 @@ def getMovieReleaseDate(imdbId):
return first_release return first_release
def _parseDate(d): def _parseDate(d):
'''
>>>_parseDate('3 March 1972')
'1972-03-03'
'''
try: try:
parsed_date = time.strptime(d, "%d %B %Y") parsed_date = time.strptime(d, "%d %B %Y")
parsed_date = '%s-%02d-%02d' % (parsed_date.tm_year, parsed_date.tm_mon, parsed_date.tm_mday) parsed_date = '%s-%02d-%02d' % (parsed_date.tm_year, parsed_date.tm_mon, parsed_date.tm_mday)
parsed_date = time.strftime('%Y-%m-%d', parsed_date)
return parsed_date return parsed_date
except: except:
import traceback
traceback.print_exc()
try: try:
parsed_date = time.strptime(d, "%B %Y") parsed_date = time.strptime(d, "%B %Y")
parsed_date = '%s-%02d-01' % (parsed_date.tm_year, parsed_date.tm_mon) parsed_date = '%s-%02d-01' % (parsed_date.tm_year, parsed_date.tm_mon)