def make_date(d):
   ''' ugly fuction to handle all kind of date formats
       as ("02-03-2012","01-FEB-12","01/23/12","11/28/06")
       which are used simultaneously by US Department of Treasure '''
   index = d.find('T')
   if index != -1:
     d = d[:index]
   if '-' in d: 
      parts = d.split('-')
      dt_type='-'
   else:
      parts = d.split('/')
      dt_type = '/'
   if parts[1].isalpha():
      month_f ='%b' if len(parts[1])==3 else '%B'
      first_f ='%d'
      second_f = '%Y' if len(parts[2])==4 else '%y'
   else:
      if int(parts[0])<=12:
         first_f = '%m'
         month_f = '%d'
         second_f = '%Y' if len(parts[2])==4 else '%y'
      else:
         if int(parts[0]) > 1000:
             first_f = '%Y'
             month_f = '%m'
             second_f = '%d'            
         else:
             first_f = '%m'
             month_f = '%d'
             second_f = '%Y' if len(parts[2])==4 else '%y'
   d_format = dt_type.join([name for name in [first_f,month_f,second_f] ])
   return dt.strptime(d,d_format).date()
 ugly fuction to handle all kind of date formats
       as ("02-03-2012","01-FEB-12","01/23/12","11/28/06")
       which are used simultaneously by US Department of Treasure 
recipes/Python/578032_XML_Pythobjectnext_generatireal_life_example/recipe-578032.py