import re import time def parseDate(str) : mons = [ 'jan', 'feb', 'mar', 'apr', 'mai', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'des' ] rxstr = r'(\d+).*(\d+).*(' + ( '|'.join(mons) ) + r')' rx = re.compile( rxstr, re.IGNORECASE ) res = rx.match( str ) d_sta = int( res.group(0) ) #d_end = res.group(1) m_sta = mons.index( res.group(2) ) now = time.localtime() y_sta = now[0] if now[1] > m_sta or ( now[1] == m_sta and now[2] > d_sta ) : y_sta += 1 return "%4d-%2d-%2d" % ( y_sta, m_sta, d_sta )