(dateString)
| 7 | } |
| 8 | |
| 9 | function parseDate(dateString) { |
| 10 | const regex = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ |
| 11 | |
| 12 | const match = dateString.match(regex) |
| 13 | |
| 14 | if (!match) { |
| 15 | throw new Error("Invalid date format. Please use 'dd/mm/yyyy'.") |
| 16 | } |
| 17 | |
| 18 | const res = { |
| 19 | day: parseInt(match[1], 10), |
| 20 | month: parseInt(match[2], 10), |
| 21 | year: parseInt(match[3], 10) |
| 22 | } |
| 23 | checkDate(res) |
| 24 | return res |
| 25 | } |
| 26 | |
| 27 | export { parseDate } |
no test coverage detected