index.js 982 B

123456789101112131415161718192021222324252627282930
  1. var isSameWeek = require('../is_same_week/index.js')
  2. /**
  3. * @category Week Helpers
  4. * @summary Is the given date in the same week as the current date?
  5. *
  6. * @description
  7. * Is the given date in the same week as the current date?
  8. *
  9. * @param {Date|String|Number} date - the date to check
  10. * @param {Object} [options] - the object with options
  11. * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
  12. * @returns {Boolean} the date is in this week
  13. *
  14. * @example
  15. * // If today is 25 September 2014, is 21 September 2014 in this week?
  16. * var result = isThisWeek(new Date(2014, 8, 21))
  17. * //=> true
  18. *
  19. * @example
  20. * // If today is 25 September 2014 and week starts with Monday
  21. * // is 21 September 2014 in this week?
  22. * var result = isThisWeek(new Date(2014, 8, 21), {weekStartsOn: 1})
  23. * //=> false
  24. */
  25. function isThisWeek (dirtyDate, dirtyOptions) {
  26. return isSameWeek(new Date(), dirtyDate, dirtyOptions)
  27. }
  28. module.exports = isThisWeek