index.js 572 B

123456789101112131415161718192021222324
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Weekday Helpers
  4. * @summary Does the given date fall on a weekend?
  5. *
  6. * @description
  7. * Does the given date fall on a weekend?
  8. *
  9. * @param {Date|String|Number} date - the date to check
  10. * @returns {Boolean} the date falls on a weekend
  11. *
  12. * @example
  13. * // Does 5 October 2014 fall on a weekend?
  14. * var result = isWeekend(new Date(2014, 9, 5))
  15. * //=> true
  16. */
  17. function isWeekend (dirtyDate) {
  18. var date = parse(dirtyDate)
  19. var day = date.getDay()
  20. return day === 0 || day === 6
  21. }
  22. module.exports = isWeekend