def ustrftime(somedate, fmt='%Y-%m-%d'):
 if (sys.version_info >= (3, 3)):
  return somedate.strftime(fmt)
 else:
  try:
   if (sys.version_info < (3, 0)):
    encoding = (getlocale(LC_TIME)[1] or 'ascii')
    return unicode(somedate.strftime(str(fmt)), encoding)
   else:
    return somedate.strftime(fmt)
  except ValueError:
   if (somedate.year >= 1900):
    raise
   fields = {'Y': somedate.year, 'm': somedate.month, 'd': somedate.day}
   if isinstance(somedate, datetime):
    fields.update({'H': somedate.hour, 'M': somedate.minute, 'S': somedate.second})
   fmt = re.sub('%([YmdHMS])', '%(\\1)02d', fmt)
   return (unicode(fmt) % fields)

def ustrftime ( somedate , fmt = '%Y-%m-%d' ) : if ( sys . version_info >= ( 3 , 3 ) ) : return somedate . strftime ( fmt ) else : try : if ( sys . version_info < ( 3 , 0 ) ) : encoding = ( getlocale ( LC_TIME ) [ 1 ] or 'ascii' ) return unicode ( somedate . strftime ( str ( fmt ) ) , encoding ) else : return somedate . strftime ( fmt ) except ValueError : if ( somedate . year >= 1900 ) : raise fields = { 'Y' : somedate . year , 'm' : somedate . month , 'd' : somedate . day } if isinstance ( somedate , datetime ) : fields . update ( { 'H' : somedate . hour , 'M' : somedate . minute , 'S' : somedate . second } ) fmt = re . sub ( '%([YmdHMS])' , '%(\\1)02d' , fmt ) return ( unicode ( fmt ) % fields )
like strftime .