index.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. var startOfISOYear = require('../start_of_iso_year/index.js')
  2. /**
  3. * @category ISO Week-Numbering Year Helpers
  4. * @summary Are the given dates in the same ISO week-numbering year?
  5. *
  6. * @description
  7. * Are the given dates in the same ISO week-numbering year?
  8. *
  9. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  10. *
  11. * @param {Date|String|Number} dateLeft - the first date to check
  12. * @param {Date|String|Number} dateRight - the second date to check
  13. * @returns {Boolean} the dates are in the same ISO week-numbering year
  14. *
  15. * @example
  16. * // Are 29 December 2003 and 2 January 2005 in the same ISO week-numbering year?
  17. * var result = isSameISOYear(
  18. * new Date(2003, 11, 29),
  19. * new Date(2005, 0, 2)
  20. * )
  21. * //=> true
  22. */
  23. function isSameISOYear (dirtyDateLeft, dirtyDateRight) {
  24. var dateLeftStartOfYear = startOfISOYear(dirtyDateLeft)
  25. var dateRightStartOfYear = startOfISOYear(dirtyDateRight)
  26. return dateLeftStartOfYear.getTime() === dateRightStartOfYear.getTime()
  27. }
  28. module.exports = isSameISOYear