Skip to content

Conversation

@UnicodingUnicorn
Copy link

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.

Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Fil
Copy link
Member

Fil commented Jun 5, 2020

Like checking that format(f)(parse(f)(x)) === x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants