This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
It seems like the System.DateOnly constructors should provide for some exceptions. What if someone enters a year outside the range 1-9999? What if they enter Feb 29 with a year that is not a leap year? What if they enter Feb 30 or Apr 31?
In these cases, it provides exceptions.
I don't see the exceptions mentioned in the online documentation for DateOnly. For instance, here is the only information provided for the constructor DateOnly(Int32, Int32, Int32).
DateOnly(Int32, Int32, Int32)
Creates a new instance of the DateOnly structure to the specified year, month, and day.
public DateOnly (int year, int month, int day);
The year (1 through 9999).
The month (1 through 12).
The day (1 through the number of days in month).
Since this is a documentation incompleteness, then you can press the “Feedback” button in documentation pages or even report the issue directly at https://github.com/dotnet/docs/issues.
OK, I did report it via feedback, but notice that even the .NET 7 (complete) version of the documentation did not provide exception information. Thanks for putting up with me in this question.
Hi @Nicholas Piazza , Welcome to Microsoft Q&A,
Can you put a link to your feedback here?
I'll keep it on record again.
I don't know how to put a link to the feedback here. I just clicked the Feedback button on the documentation site (https://learn.microsoft.com/en-us/dotnet/api/system.dateonly.-ctor?view=net-8.0) and filled it in.