isBefore.cjs 704 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. exports.isBefore = isBefore;
  3. var _index = require("./toDate.cjs");
  4. /**
  5. * @name isBefore
  6. * @category Common Helpers
  7. * @summary Is the first date before the second one?
  8. *
  9. * @description
  10. * Is the first date before the second one?
  11. *
  12. * @param date - The date that should be before the other one to return true
  13. * @param dateToCompare - The date to compare with
  14. *
  15. * @returns The first date is before the second date
  16. *
  17. * @example
  18. * // Is 10 July 1989 before 11 February 1987?
  19. * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
  20. * //=> false
  21. */
  22. function isBefore(date, dateToCompare) {
  23. return +(0, _index.toDate)(date) < +(0, _index.toDate)(dateToCompare);
  24. }