isValid.d.cts 823 B

1234567891011121314151617181920212223242526272829303132
  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. * @param date - The date to check
  14. *
  15. * @returns The date is valid
  16. *
  17. * @example
  18. * // For the valid date:
  19. * const result = isValid(new Date(2014, 1, 31))
  20. * //=> true
  21. *
  22. * @example
  23. * // For the value, convertible into a date:
  24. * const result = isValid(1393804800000)
  25. * //=> true
  26. *
  27. * @example
  28. * // For the invalid date:
  29. * const result = isValid(new Date(''))
  30. * //=> false
  31. */
  32. export declare function isValid(date: unknown): boolean;