MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / getDaysOfWeek

Function getDaysOfWeek

core/src/components/datetime/utils/data.ts:73–96  ·  view source on GitHub ↗
(locale: string, mode: Mode, firstDayOfWeek = 0)

Source from the content-addressed store, hash-verified

71 * or "T".
72 */
73export const getDaysOfWeek = (locale: string, mode: Mode, firstDayOfWeek = 0) => {
74 /**
75 * Nov 1st, 2020 starts on a Sunday.
76 * ion-datetime assumes weeks start on Sunday,
77 * but is configurable via `firstDayOfWeek`.
78 */
79 const weekdayFormat = mode === 'ios' ? 'short' : 'narrow';
80 const intl = new Intl.DateTimeFormat(locale, { weekday: weekdayFormat });
81 const startDate = new Date('11/01/2020');
82 const daysOfWeek = [];
83
84 /**
85 * For each day of the week,
86 * get the day name.
87 */
88 for (let i = firstDayOfWeek; i < firstDayOfWeek + 7; i++) {
89 const currentDate = new Date(startDate);
90 currentDate.setDate(currentDate.getDate() + i);
91
92 daysOfWeek.push(intl.format(currentDate));
93 }
94
95 return daysOfWeek;
96};
97
98/**
99 * Returns an array containing all of the

Callers 2

renderCalendarHeaderMethod · 0.90
data.spec.tsFile · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected