1 | import type { Locale } from "../lib/dateLib.js";
|
2 | import { dateLib as defaultDateLib } from "../lib/index.js";
|
3 | import type { DateLib } from "../types/index.js";
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export function getWeekdays(
|
10 | locale?: Locale | undefined,
|
11 |
|
12 | weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined,
|
13 |
|
14 | ISOWeek?: boolean | undefined,
|
15 |
|
16 | dateLib: DateLib = defaultDateLib
|
17 | ): Date[] {
|
18 | const start = ISOWeek
|
19 | ? dateLib.startOfISOWeek(new dateLib.Date())
|
20 | : dateLib.startOfWeek(new dateLib.Date(), { locale, weekStartsOn });
|
21 |
|
22 | const days = [];
|
23 | for (let i = 0; i < 7; i++) {
|
24 | const day = dateLib.addDays(start, i);
|
25 | days.push(day);
|
26 | }
|
27 | return days;
|
28 | }
|