| 67 | } |
| 68 | |
| 69 | function parseMonthIndex(month: string): number | null { |
| 70 | const match = /^(\d{4})-(\d{2})$/.exec(month) |
| 71 | if (!match) return null |
| 72 | |
| 73 | const year = Number.parseInt(match[1], 10) |
| 74 | const monthNumber = Number.parseInt(match[2], 10) |
| 75 | if (!Number.isFinite(year) || monthNumber < 1 || monthNumber > 12) return null |
| 76 | |
| 77 | return year * 12 + monthNumber - 1 |
| 78 | } |
| 79 | |
| 80 | function getActiveMonthIndexes(activeMonths: readonly string[]): number[] { |
| 81 | return [...new Set(activeMonths.map(parseMonthIndex).filter((month): month is number => month !== null))].sort( |