Validate input for improper leap dates and short months#72
Validate input for improper leap dates and short months#72UnicodingUnicorn wants to merge 1 commit intod3:mainfrom
Conversation
mbostock
left a comment
There was a problem hiding this comment.
I suspect there’s an easier way of implementing this rather than re-implementing the calendaring logic by hand. For example, if the resulting date.getDate() is not equal to d.d, then rollover probably happened.
But more importantly, I don’t think it makes sense to implement this validation logic just for day-in-month. If we’re going to do this, wouldn’t we also want to return null if you specify out-of-range values for other fields, such as months, hours, minutes, seconds?
And lastly, I’m very wary about simply changing behavior rather than letting people opt-in to stricter validation. If this PR lands, dates that previously parsed will now return null. While that might be strictly correct, it will likely be surprising.
|
Like checking that |
With reference to Issue #47. Currently checks for trying to specify a leap date on non-leap years, and a 31 on months with only 30 days.