isValid.d.mts 1007 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @name isValid
  3. * @category Common Helpers
  4. * @summary Is the given date valid?
  5. *
  6. * @description
  7. * Returns false if argument is Invalid Date and true otherwise.
  8. * Argument is converted to Date using `toDate`. See [toDate](https://date-fns.org/docs/toDate)
  9. * Invalid Date is a Date, whose time value is NaN.
  10. *
  11. * Time value of Date: http://es5.github.io/#x15.9.1.1
  12. *
  13. * @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).
  14. *
  15. * @param date - The date to check
  16. *
  17. * @returns The date is valid
  18. *
  19. * @example
  20. * // For the valid date:
  21. * const result = isValid(new Date(2014, 1, 31))
  22. * //=> true
  23. *
  24. * @example
  25. * // For the value, convertable into a date:
  26. * const result = isValid(1393804800000)
  27. * //=> true
  28. *
  29. * @example
  30. * // For the invalid date:
  31. * const result = isValid(new Date(''))
  32. * //=> false
  33. */
  34. export declare function isValid(date: unknown): boolean;