class_docstr: Object representing a locale.
  
  After calling one of `load_translations` or `load_gettext_translations`,
  call `get` or `get_closest` to get a Locale object.
docstr: Formats the given date.
  
  By default, we return a relative time (e.g., "2 minutes ago"). You
  can return an absolute date string with ``relative=False``.
  
  You can force a full format date ("July 10, 1980") with
  ``full_format=True``.
  
  This method is primarily intended for dates in the past.
  For dates in the future, we fall back to full format.
  
  .. versionchanged:: 6.4
     Aware `datetime.datetime` objects are now supported (naive
     datetimes are still assumed to be UTC).
docstr_tok: ["Formats","the","given","date",".","By","default",",","we","return","a","relative","time","(","e.g.",",","``","2","minutes","ago","''",")",".","You","can","return","an","absolute","date","string","with","``","relative=False","``",".","You","can","force","a","full","format","date","(","``","July","10",",","1980","''",")","with","``","full_format=True","``",".","This","method","is","primarily","intended","for","dates","in","the","past",".","For","dates","in","the","future",",","we","fall","back","to","full","format",".","..","versionchanged",":",":","6.4","Aware","`","datetime.datetime","`","objects","are","now","supported","(","naive","datetimes","are","still","assumed","to","be","UTC",")","."]
code: def format_date(
      self,
      date: Union[int, float, datetime.datetime],
      gmt_offset: int = 0,
      relative: bool = True,
      shorter: bool = False,
      full_format: bool = False,
  ) -> str:
      """Formats the given date.
  
      By default, we return a relative time (e.g., "2 minutes ago"). You
      can return an absolute date string with ``relative=False``.
  
      You can force a full format date ("July 10, 1980") with
      ``full_format=True``.
  
      This method is primarily intended for dates in the past.
      For dates in the future, we fall back to full format.
  
      .. versionchanged:: 6.4
         Aware `datetime.datetime` objects are now supported (naive
         datetimes are still assumed to be UTC).
      """
      if isinstance(date, (int, float)):
          date = datetime.datetime.fromtimestamp(
              date, datetime.timezone.utc
          )
      if date.tzinfo is None:
          date = date.replace(tzinfo=datetime.timezone.utc)
      now = datetime.datetime.now(datetime.timezone.utc)
      if date > now:
          if relative and (date - now).seconds < 60:
              # Due to click skew, things are some things slightly
              # in the future. Round timestamps in the immediate
              # future down to now in relative mode.
              date = now
          else:
              # Otherwise, future dates always use the full format.
              full_format = True
      local_date = date - datetime.timedelta(minutes=gmt_offset)
      local_now = now - datetime.timedelta(minutes=gmt_offset)
      local_yesterday = local_now - datetime.timedelta(hours=24)
      difference = now - date
      seconds = difference.seconds
      days = difference.days
  
      _ = self.translate
      format = None
      if not full_format:
          if relative and days == 0:
              if seconds < 50:
                  return _(
                      "1 second ago", "%(seconds)d seconds ago", seconds
                  ) % {"seconds": seconds}
  
              if seconds < 50 * 60:
                  minutes = round(seconds / 60.0)
                  return _(
                      "1 minute ago", "%(minutes)d minutes ago", minutes
                  ) % {"minutes": minutes}
  
              hours = round(seconds / (60.0 * 60))
              return _("1 hour ago", "%(hours)d hours ago", hours) % {
                  "hours": hours
              }
  
          if days == 0:
              format = _("%(time)s")
          elif (
              days == 1
              and local_date.day == local_yesterday.day
              and relative
          ):
              format = (
                  _("yesterday")
                  if shorter
                  else _("yesterday at %(time)s")
              )
          elif days < 5:
              format = (
                  _("%(weekday)s")
                  if shorter
                  else _("%(weekday)s at %(time)s")
              )
          elif (
              days < 334
          ):  # 11mo, since confusing for same month last year
              format = (
                  _("%(month_name)s %(day)s")
                  if shorter
                  else _("%(month_name)s %(day)s at %(time)s")
              )
  
      if format is None:
          format = (
              _("%(month_name)s %(day)s, %(year)s")
              if shorter
              else _("%(month_name)s %(day)s, %(year)s at %(time)s")
          )
  
      tfhour_clock = self.code not in ("en", "en_US", "zh_CN")
      if tfhour_clock:
          str_time = "%d:%02d" % (local_date.hour, local_date.minute)
      elif self.code == "zh_CN":
          str_time = "%s%d:%02d" % (
              ("\u4e0a\u5348", "\u4e0b\u5348")[local_date.hour >= 12],
              local_date.hour % 12 or 12,
              local_date.minute,
          )
      else:
          str_time = "%d:%02d %s" % (
              local_date.hour % 12 or 12,
              local_date.minute,
              ("am", "pm")[local_date.hour >= 12],
          )
  
      return format % {
          "month_name": self._months[local_date.month - 1],
          "weekday": self._weekdays[local_date.weekday()],
          "day": str(local_date.day),
          "year": str(local_date.year),
          "time": str_time,
      }
  
imports: import codecs
  import csv
  import datetime
  import gettext
  import glob
  import os
  import re
  from tornado import escape
  from tornado.log import gen_log
  from tornado._locale_data import LOCALE_NAMES
  from typing import Iterable, Any, Union, Dict, Optional
label_desc: Use image node_id 6 for calling the Locale obj's underlying member method code with example usage: obj.format_date(date, gmt_offset, relative, shorter, full_format) and returns: unknown, unknown, unknown, unknown