formatRFC7231.d.mts 891 B

12345678910111213141516171819202122232425
  1. /**
  2. * @name formatRFC7231
  3. * @category Common Helpers
  4. * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1).
  5. *
  6. * @description
  7. * Return the formatted date string in RFC 7231 format.
  8. * The result will always be in UTC timezone.
  9. *
  10. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  11. *
  12. * @param date - The original date
  13. *
  14. * @returns The formatted date string
  15. *
  16. * @throws `date` must not be Invalid Date
  17. *
  18. * @example
  19. * // Represent 18 September 2019 in RFC 7231 format:
  20. * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52))
  21. * //=> 'Wed, 18 Sep 2019 19:00:52 GMT'
  22. */
  23. export declare function formatRFC7231<DateType extends Date>(
  24. date: DateType | number | string,
  25. ): string;