Fix runtime error Date object
I think the best approach would be to clamp the input year so that it's not abnormally large. The valid year range is [-271821, 275760], so clamping to a slightly larger range than that should be enough, making sure that invalid year values remain invalid.
It's not as easy. We can't clamp the input year, because there is no restriction for the arguments of the Date constructor, only the output Date object should be in the allowed interval. for example new Date(-271822, 16) is valid Date, but new Date(-271822, 15) is invalid.
That's why I said clamping it to a slightly larger range. That will filter out abnormally large input values, that should be invalid regardless, then the rest will be handled by the conversion logic correctly without overflowing.
https://262.ecma-international.org/12.0/#eqn-DaysFromYear
The latest spec clarifies that we should handle year as mathematical value (Arbitrary real numbers, used as the default numeric type) and the result should be Number (double): DayFromYear(y) = 𝔽(365 × (ℝ(y) - 1970) + floor((ℝ(y) - 1969) / 4) - floor((ℝ(y) - 1901) / 100) + floor((ℝ(y) - 1601) / 400))