isSunday.mjs 686 B

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