« Very cunning Python based Universal Feed Parser | Main | New do_sql.php »

August 03, 2006

Parsing mutliple date formats in Python

try:
    date_time = datetime.datetime(*time.strptime(this_val, "%d/%m/%Y")[0:5])
except:
    pass
try:
    date_time = datetime.datetime(*time.strptime(this_val, "%B %Y")[0:5])
except:
     pass
try:
     date_time = datetime.datetime(*time.strptime(this_val, "%Y")[0:5])
except:
     pass
print "<!--" + str(date_time) + "-->"

Tags: Python

Posted by pj at August 3, 2006 02:58 PM

Comments