(value: string)
| 426 | * already is in a supported format. |
| 427 | */ |
| 428 | export function reformatDateString(value: string) { |
| 429 | const yearMonth = /^(\d{4})(\d{1,2})$/; |
| 430 | const yearMonthDay = /^(\d{4})-?(\d{2})-?(\d{1,2})$/; |
| 431 | |
| 432 | let match = value.match(yearMonth); |
| 433 | |
| 434 | if (match) { |
| 435 | return `${match[1]}-${match[2]}`; |
| 436 | } |
| 437 | |
| 438 | match = value.match(yearMonthDay); |
| 439 | |
| 440 | if (match) { |
| 441 | return `${match[1]}-${match[2]}-${match[3]}`; |
| 442 | } |
| 443 | |
| 444 | return value; |
| 445 | } |
no test coverage detected