getISODay.cjs 810 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. exports.getISODay = getISODay;
  3. var _index = require("./toDate.cjs");
  4. /**
  5. * The {@link getISODay} function options.
  6. */
  7. /**
  8. * @name getISODay
  9. * @category Weekday Helpers
  10. * @summary Get the day of the ISO week of the given date.
  11. *
  12. * @description
  13. * Get the day of the ISO week of the given date,
  14. * which is 7 for Sunday, 1 for Monday etc.
  15. *
  16. * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
  17. *
  18. * @param date - The given date
  19. * @param options - An object with options
  20. *
  21. * @returns The day of ISO week
  22. *
  23. * @example
  24. * // Which day of the ISO week is 26 February 2012?
  25. * const result = getISODay(new Date(2012, 1, 26))
  26. * //=> 7
  27. */
  28. function getISODay(date, options) {
  29. const day = (0, _index.toDate)(date, options?.in).getDay();
  30. return day === 0 ? 7 : day;
  31. }