Errors with impossible date
Closed this issue · 1 comments
EgoLaparra commented
The parser takes a long to time to parse impossible dates, e.g. "31 April 2018", and then crashes throwing a java.time.DateTimeException
.
bethard commented
This is maybe not the most beautiful solution, but putting something like this in the constructor of IntersectionRI
at least causes the error to show up nice and early:
for {
month <- repeatingIntervals.collectFirst{ case RepeatingField(ChronoField.MONTH_OF_YEAR, month, _, _) => month }
day <- repeatingIntervals.collectFirst{ case RepeatingField(ChronoField.DAY_OF_MONTH, day, _, _) => day}
} {
java.time.MonthDay.of(month.toInt, day.toInt) // throws an exception if this is an invalid combination
}
I don't know how many other things we might end up special-casing this way, so I'm a little afraid of the precedent, but it's probably worth doing this to avoid searching forever for an impossible time.