MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / generateMonths

Function generateMonths

core/src/components/datetime/utils/data.ts:328–345  ·  view source on GitHub ↗
(refParts: DatetimeParts, forcedDate?: DatetimeParts)

Source from the content-addressed store, hash-verified

326 * current, and and next months.
327 */
328export const generateMonths = (refParts: DatetimeParts, forcedDate?: DatetimeParts): DatetimeParts[] => {
329 const current = { month: refParts.month, year: refParts.year, day: refParts.day };
330
331 /**
332 * If we're forcing a month to appear, and it's different from the current month,
333 * ensure it appears by replacing the next or previous month as appropriate.
334 */
335 if (forcedDate !== undefined && (refParts.month !== forcedDate.month || refParts.year !== forcedDate.year)) {
336 const forced = { month: forcedDate.month, year: forcedDate.year, day: forcedDate.day };
337 const forcedMonthIsBefore = isBefore(forced, current);
338
339 return forcedMonthIsBefore
340 ? [forced, current, getNextMonth(refParts)]
341 : [getPreviousMonth(refParts), current, forced];
342 }
343
344 return [getPreviousMonth(refParts), current, getNextMonth(refParts)];
345};
346
347export const getMonthColumnData = (
348 locale: string,

Callers 3

renderCalendarBodyMethod · 0.90
data.spec.tsFile · 0.90

Calls 3

isBeforeFunction · 0.90
getNextMonthFunction · 0.90
getPreviousMonthFunction · 0.90

Tested by

no test coverage detected