parseISO.d.mts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * The {@link parseISO} function options.
  3. */
  4. export interface ParseISOOptions {
  5. /** The additional number of digits in the extended year format */
  6. additionalDigits?: 0 | 1 | 2;
  7. }
  8. /**
  9. * @name parseISO
  10. * @category Common Helpers
  11. * @summary Parse ISO string
  12. *
  13. * @description
  14. * Parse the given string in ISO 8601 format and return an instance of Date.
  15. *
  16. * Function accepts complete ISO 8601 formats as well as partial implementations.
  17. * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
  18. *
  19. * If the argument isn't a string, the function cannot parse the string or
  20. * the values are invalid, it returns Invalid Date.
  21. *
  22. * @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).
  23. *
  24. * @param argument - The value to convert
  25. * @param options - An object with options
  26. *
  27. * @returns The parsed date in the local time zone
  28. *
  29. * @example
  30. * // Convert string '2014-02-11T11:30:30' to date:
  31. * const result = parseISO('2014-02-11T11:30:30')
  32. * //=> Tue Feb 11 2014 11:30:30
  33. *
  34. * @example
  35. * // Convert string '+02014101' to date,
  36. * // if the additional number of digits in the extended year format is 1:
  37. * const result = parseISO('+02014101', { additionalDigits: 1 })
  38. * //=> Fri Apr 11 2014 00:00:00
  39. */
  40. export declare function parseISO(
  41. argument: string,
  42. options?: ParseISOOptions,
  43. ): Date;