-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert NaiveDate::from_weekday_of_month
to return Result
#1512
Conversation
defb504
to
776392a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 0.5.x #1512 +/- ##
=======================================
Coverage 94.02% 94.02%
=======================================
Files 37 37
Lines 16974 16980 +6
=======================================
+ Hits 15960 15966 +6
Misses 1014 1014 ☔ View full report in Codecov by Sentry. |
/// - [`Error::DoesNotExist`] if the specified day does not exist in that month | ||
/// (for example the 5th Monday of Apr. 2023). | ||
/// - [`Error::InvalidArgument`] if the value for `month` or `n` is invalid. | ||
/// - [`Error::OutOfRange`] if `year` is out of range for `NaiveDate`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess these are ordered alphabetically, and I haven't really reviewed for this before, but IMO it would be nice to order these more semantically, roughly in the order they get checked? Like, it feels like InvalidArgument
should go first here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not order them alphabetically, but by how often I expect users to encounter them.
DoesNotExist
should be quite normal, as it totally depends on the calendar. InvalidArgument
shows the input is not checked for correctness before, which I think is less common. OutOfRange
is for dates so many thousands of years into the past or future that I think them to be are real edge cases.
Does that sound like a reasonable order?
It feels like that should be a separate method, (I guess an alternative would be to use |
|
A small PR converting just a single method.
In my personal use I found the way the method currently works inconvenient.
It is not uncommon for scheduling applications to equal some recurring thing on the 5th
Weekday
of the month with the lastWeekday
of the month. No matter if that turns out to be the 4th or the 5thWeekday
.Is that practise something we want to support? And if so do we want to adjust this method or add another one?