formatISO9075.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.js";
  2. /**
  3. * The {@link formatISO9075} function options.
  4. */
  5. export interface FormatISO9075Options
  6. extends ISOFormatOptions,
  7. ContextOptions<Date> {}
  8. /**
  9. * @name formatISO9075
  10. * @category Common Helpers
  11. * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format).
  12. *
  13. * @description
  14. * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date.
  15. *
  16. * @param date - The original date
  17. * @param options - An object with options.
  18. *
  19. * @returns The formatted date string
  20. *
  21. * @throws `date` must not be Invalid Date
  22. *
  23. * @example
  24. * // Represent 18 September 2019 in ISO 9075 format:
  25. * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52))
  26. * //=> '2019-09-18 19:00:52'
  27. *
  28. * @example
  29. * // Represent 18 September 2019 in ISO 9075, short format:
  30. * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
  31. * //=> '20190918 190052'
  32. *
  33. * @example
  34. * // Represent 18 September 2019 in ISO 9075 format, date only:
  35. * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
  36. * //=> '2019-09-18'
  37. *
  38. * @example
  39. * // Represent 18 September 2019 in ISO 9075 format, time only:
  40. * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
  41. * //=> '19:00:52'
  42. */
  43. export declare function formatISO9075(
  44. date: DateArg<Date> & {},
  45. options?: FormatISO9075Options,
  46. ): string;