code: def formatdate(timeval=None, localtime=False, usegmt=False):
      """Returns a date string as specified by RFC 2822, e.g.:
  
      Fri, 09 Nov 2001 01:08:47 -0000
  
      Optional timeval if given is a floating point time value as accepted by
      gmtime() and localtime(), otherwise the current time is used.
  
      Optional localtime is a flag that when True, interprets timeval, and
      returns a date relative to the local timezone instead of UTC, properly
      taking daylight savings time into account.
  
      Optional argument usegmt means that the timezone is written out as
      an ascii string, not numeric one (so "GMT" instead of "+0000"). This
      is needed for HTTP, and is only used when localtime==False.
      """
      # Note: we cannot use strftime() because that honors the locale and RFC
      # 2822 requires that day and month names be the English abbreviations.
      if timeval is None:
          timeval = time.time()
      dt = datetime.datetime.fromtimestamp(
          timeval, datetime.timezone.utc
      )
  
      if localtime:
          dt = dt.astimezone()
          usegmt = False
      elif not usegmt:
          dt = dt.replace(tzinfo=None)
      return format_datetime(dt, usegmt)
  
imports: import os
  import re
  import time
  import datetime
  import urllib.parse
  from email._parseaddr import quote
  from email._parseaddr import AddressList
  from email._parseaddr import mktime_tz
  from email._parseaddr import parsedate, parsedate_tz, _parsedate_tz
label_desc: Use image node_id 11 for calling a global function with example usage: formatdate(timeval, localtime, usegmt) and returns: format_datetime