def formatdate(timeval=None, localtime=False, usegmt=False):
 if (timeval is None):
  timeval = time.time()
 if localtime:
  now = time.localtime(timeval)
  if (time.daylight and now[(-1)]):
   offset = time.altzone
  else:
   offset = time.timezone
  (hours, minutes) = divmod(abs(offset), 3600)
  if (offset > 0):
   sign = '-'
  else:
   sign = '+'
  zone = ('%s%02d%02d' % (sign, hours, (minutes // 60)))
 else:
  now = time.gmtime(timeval)
  if usegmt:
   zone = 'GMT'
  else:
   zone = '-0000'
 return ('%s, %02d %s %04d %02d:%02d:%02d %s' % (['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]], now[2], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][(now[1] - 1)], now[0], now[3], now[4], now[5], zone))

def formatdate ( timeval = None , localtime = False , usegmt = False ) : if ( timeval is None ) : timeval = time . time ( ) if localtime : now = time . localtime ( timeval ) if ( time . daylight and now [ ( - 1 ) ] ) : offset = time . altzone else : offset = time . timezone ( hours , minutes ) = divmod ( abs ( offset ) , 3600 ) if ( offset > 0 ) : sign = '-' else : sign = '+' zone = ( '%s%02d%02d' % ( sign , hours , ( minutes // 60 ) ) ) else : now = time . gmtime ( timeval ) if usegmt : zone = 'GMT' else : zone = '-0000' return ( '%s, %02d %s %04d %02d:%02d:%02d %s' % ( [ 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' ] [ now [ 6 ] ] , now [ 2 ] , [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] [ ( now [ 1 ] - 1 ) ] , now [ 0 ] , now [ 3 ] , now [ 4 ] , now [ 5 ] , zone ) )
returns time format preferred for internet standards .