isMonday.mjs 686 B

123456789101112131415161718192021222324252627
  1. import { toDate } from "./toDate.mjs";
  2. /**
  3. * @name isMonday
  4. * @category Weekday Helpers
  5. * @summary Is the given date Monday?
  6. *
  7. * @description
  8. * Is the given date Monday?
  9. *
  10. * @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).
  11. *
  12. * @param date - The date to check
  13. *
  14. * @returns The date is Monday
  15. *
  16. * @example
  17. * // Is 22 September 2014 Monday?
  18. * const result = isMonday(new Date(2014, 8, 22))
  19. * //=> true
  20. */
  21. export function isMonday(date) {
  22. return toDate(date).getDay() === 1;
  23. }
  24. // Fallback for modularized imports:
  25. export default isMonday;