All pastes #770869 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-12 17:31 UTC
rendered paste body
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-%2dT00:00:00Z" % ( y_sta, m_sta, d_sta )