UNPKG

824 BJavaScriptView Raw
1import { toDate } from "./toDate.js";
2
3/**
4 * The {@link getISODay} function options.
5 */
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 */
28export function getISODay(date, options) {
29 const day = toDate(date, options?.in).getDay();
30 return day === 0 ? 7 : day;
31}
32
33// Fallback for modularized imports:
34export default getISODay;