1 | import { toUTCDate } from './helpers/to-utc-date.js';
|
2 | export function getWeekdays(options) {
|
3 | const { firstDayOfWeek = 0, showWeekNumber = false, weekLabel, longWeekdayFormat, narrowWeekdayFormat, } = options || {};
|
4 | const fixedFirstDayOfWeek = 1 + ((firstDayOfWeek + (firstDayOfWeek < 0 ? 7 : 0)) % 7);
|
5 | const weekLabel2 = weekLabel || 'Wk';
|
6 | const initialValue = showWeekNumber ?
|
7 | [{
|
8 | label: weekLabel2 === 'Wk' ? 'Week' : weekLabel2,
|
9 | value: weekLabel2,
|
10 | }] :
|
11 | [];
|
12 | const weekdays = Array.from(Array(7)).reduce((p, _, i) => {
|
13 | const d = toUTCDate(2017, 0, fixedFirstDayOfWeek + i);
|
14 | p.push({
|
15 | label: longWeekdayFormat(d),
|
16 | value: narrowWeekdayFormat(d),
|
17 | });
|
18 | return p;
|
19 | }, initialValue);
|
20 | return weekdays;
|
21 | }
|
22 |
|
\ | No newline at end of file |