index.js 718 B

1234567891011121314151617181920212223242526272829303132
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Weekday Helpers
  4. * @summary Get the day of the ISO week of the given date.
  5. *
  6. * @description
  7. * Get the day of the ISO week of the given date,
  8. * which is 7 for Sunday, 1 for Monday etc.
  9. *
  10. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  11. *
  12. * @param {Date|String|Number} date - the given date
  13. * @returns {Number} the day of ISO week
  14. *
  15. * @example
  16. * // Which day of the ISO week is 26 February 2012?
  17. * var result = getISODay(new Date(2012, 1, 26))
  18. * //=> 7
  19. */
  20. function getISODay (dirtyDate) {
  21. var date = parse(dirtyDate)
  22. var day = date.getDay()
  23. if (day === 0) {
  24. day = 7
  25. }
  26. return day
  27. }
  28. module.exports = getISODay