code: def encode_pdf_date(d: datetime) -> str:
      
  
      # The formatting of %Y is not consistent as described in
      # https://bugs.python.org/issue13305 and underspecification in libc.
      # So explicitly format the year with leading zeros
      s = "{:04d}".format(d.year)
      s += d.strftime(r'%m%d%H%M%S')
      tz = d.strftime('%z')
      if tz:
          sign, tz_hours, tz_mins = tz[0], tz[1:3], tz[3:5]
          s += "{}{}'{}'".format(sign, tz_hours, tz_mins)
      return s
docs: Encode Python datetime object as PDF date string
  
      From Adobe pdfmark manual:
      (D:YYYYMMDDHHmmSSOHH'mm')
      D: is an optional prefix. YYYY is the year. All fields after the year are
      optional. MM is the month (01-12), DD is the day (01-31), HH is the
      hour (00-23), mm are the minutes (00-59), and SS are the seconds
      (00-59). The remainder of the string defines the relation of local
      time to GMT. O is either + for a positive difference (local time is
      later than GMT) or - (minus) for a negative difference. HH' is the
      absolute value of the offset from GMT in hours, and mm' is the
      absolute value of the offset in minutes. If no GMT information is
      specified, the relation between the specified time and GMT is
      considered unknown. Regardless of whether or not GMT
      information is specified, the remainder of the string should specify
      the local time.