You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 regels
1.0 KiB

  1. import toDate from '../toDate/index.js';
  2. import requiredArgs from '../_lib/requiredArgs/index.js';
  3. /**
  4. * @name getISODay
  5. * @category Weekday Helpers
  6. * @summary Get the day of the ISO week of the given date.
  7. *
  8. * @description
  9. * Get the day of the ISO week of the given date,
  10. * which is 7 for Sunday, 1 for Monday etc.
  11. *
  12. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  13. *
  14. * ### v2.0.0 breaking changes:
  15. *
  16. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  17. *
  18. * @param {Date|Number} date - the given date
  19. * @returns {Number} the day of ISO week
  20. * @throws {TypeError} 1 argument required
  21. *
  22. * @example
  23. * // Which day of the ISO week is 26 February 2012?
  24. * var result = getISODay(new Date(2012, 1, 26))
  25. * //=> 7
  26. */
  27. export default function getISODay(dirtyDate) {
  28. requiredArgs(1, arguments);
  29. var date = toDate(dirtyDate);
  30. var day = date.getDay();
  31. if (day === 0) {
  32. day = 7;
  33. }
  34. return day;
  35. }