(format?: string)
| 200 | * Extracts separate month and year format strings from a combined month_format, e.g. "MMM YY". |
| 201 | */ |
| 202 | export function extractFormats(format?: string): { |
| 203 | monthFormat: string; |
| 204 | yearFormat: string; |
| 205 | } { |
| 206 | if (!format) { |
| 207 | return {monthFormat: 'MMMM', yearFormat: 'YYYY'}; |
| 208 | } |
| 209 | |
| 210 | // Extract month tokens (MMMM, MMM, MM, M) |
| 211 | const monthMatch = format.match(/M{1,4}/); |
| 212 | const monthFormat = monthMatch ? monthMatch[0] : 'MMMM'; |
| 213 | |
| 214 | // Extract year tokens (YYYY, YY) |
| 215 | const yearMatch = format.match(/Y{2,4}/); |
| 216 | const yearFormat = yearMatch ? yearMatch[0] : 'YYYY'; |
| 217 | |
| 218 | return {monthFormat, yearFormat}; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Generates month options for a dropdown based on a format string. |
no test coverage detected
searching dependent graphs…