isYesterday.cjs 922 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. exports.isYesterday = isYesterday;
  3. var _index = require("./constructFrom.cjs");
  4. var _index2 = require("./constructNow.cjs");
  5. var _index3 = require("./isSameDay.cjs");
  6. var _index4 = require("./subDays.cjs");
  7. /**
  8. * The {@link isYesterday} function options.
  9. */
  10. /**
  11. * @name isYesterday
  12. * @category Day Helpers
  13. * @summary Is the given date yesterday?
  14. * @pure false
  15. *
  16. * @description
  17. * Is the given date yesterday?
  18. *
  19. * @param date - The date to check
  20. * @param options - An object with options
  21. *
  22. * @returns The date is yesterday
  23. *
  24. * @example
  25. * // If today is 6 October 2014, is 5 October 14:00:00 yesterday?
  26. * const result = isYesterday(new Date(2014, 9, 5, 14, 0))
  27. * //=> true
  28. */
  29. function isYesterday(date, options) {
  30. return (0, _index3.isSameDay)(
  31. (0, _index.constructFrom)(options?.in || date, date),
  32. (0, _index4.subDays)((0, _index2.constructNow)(options?.in || date), 1),
  33. );
  34. }