def _regexify_subfmts(subfmts):
 new_subfmts = []
 for subfmt_tuple in subfmts:
  subfmt_in = subfmt_tuple[1]
  for (strptime_code, regex) in ((u'%Y', u'(?P<year>\\d\\d\\d\\d)'), (u'%m', u'(?P<mon>\\d{1,2})'), (u'%d', u'(?P<mday>\\d{1,2})'), (u'%H', u'(?P<hour>\\d{1,2})'), (u'%M', u'(?P<min>\\d{1,2})'), (u'%S', u'(?P<sec>\\d{1,2})')):
   subfmt_in = subfmt_in.replace(strptime_code, regex)
  if (u'%' not in subfmt_in):
   subfmt_tuple = (subfmt_tuple[0], re.compile((subfmt_in + u'$')), subfmt_tuple[2])
  new_subfmts.append(subfmt_tuple)
 return tuple(new_subfmts)

def _regexify_subfmts ( subfmts ) : new_subfmts = [ ] for subfmt_tuple in subfmts : subfmt_in = subfmt_tuple [ 1 ] for ( strptime_code , regex ) in ( ( u'%Y' , u'(?P<year>\\d\\d\\d\\d)' ) , ( u'%m' , u'(?P<mon>\\d{1,2})' ) , ( u'%d' , u'(?P<mday>\\d{1,2})' ) , ( u'%H' , u'(?P<hour>\\d{1,2})' ) , ( u'%M' , u'(?P<min>\\d{1,2})' ) , ( u'%S' , u'(?P<sec>\\d{1,2})' ) ) : subfmt_in = subfmt_in . replace ( strptime_code , regex ) if ( u'%' not in subfmt_in ) : subfmt_tuple = ( subfmt_tuple [ 0 ] , re . compile ( ( subfmt_in + u'$' ) ) , subfmt_tuple [ 2 ] ) new_subfmts . append ( subfmt_tuple ) return tuple ( new_subfmts )
iterate through each of the sub-formats and try substituting simple regular expressions for the strptime codes for year .