(refParts: DatetimeParts, forcedDate?: DatetimeParts)
| 326 | * current, and and next months. |
| 327 | */ |
| 328 | export 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 | |
| 347 | export const getMonthColumnData = ( |
| 348 | locale: string, |
no test coverage detected