def rfc822date(timeinfo=None, local=1):
 if (not timeinfo):
  if local:
   timeinfo = time.localtime()
  else:
   timeinfo = time.gmtime()
 if local:
  if timeinfo[8]:
   tz = (- time.altzone)
  else:
   tz = (- time.timezone)
  (tzhr, tzmin) = divmod(abs(tz), 3600)
  if tz:
   tzhr *= int((abs(tz) // tz))
  (tzmin, tzsec) = divmod(tzmin, 60)
 else:
  (tzhr, tzmin) = (0, 0)
 return ('%s, %02d %s %04d %02d:%02d:%02d %+03d%02d' % (['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][timeinfo[6]], timeinfo[2], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][(timeinfo[1] - 1)], timeinfo[0], timeinfo[3], timeinfo[4], timeinfo[5], tzhr, tzmin))

def rfc822date ( timeinfo = None , local = 1 ) : if ( not timeinfo ) : if local : timeinfo = time . localtime ( ) else : timeinfo = time . gmtime ( ) if local : if timeinfo [ 8 ] : tz = ( - time . altzone ) else : tz = ( - time . timezone ) ( tzhr , tzmin ) = divmod ( abs ( tz ) , 3600 ) if tz : tzhr *= int ( ( abs ( tz ) // tz ) ) ( tzmin , tzsec ) = divmod ( tzmin , 60 ) else : ( tzhr , tzmin ) = ( 0 , 0 ) return ( '%s, %02d %s %04d %02d:%02d:%02d %+03d%02d' % ( [ 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' ] [ timeinfo [ 6 ] ] , timeinfo [ 2 ] , [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] [ ( timeinfo [ 1 ] - 1 ) ] , timeinfo [ 0 ] , timeinfo [ 3 ] , timeinfo [ 4 ] , timeinfo [ 5 ] , tzhr , tzmin ) )
format an rfc-2822 compliant date string .