Add Time.month_week_date#15620
Merged
straight-shoota merged 2 commits intocrystal-lang:masterfrom Apr 24, 2025
Merged
Conversation
Sija
reviewed
Apr 1, 2025
| # * `year`: `1..9999` | ||
| # * `month`: `1..12` | ||
| # * `week`: `1..5` | ||
| # * `day_of_week`: `0..7` |
Contributor
There was a problem hiding this comment.
I think this should be either 1..7 or 0..6 (or 0...7)
Member
There was a problem hiding this comment.
This is congruent with DayOfWeek.from_value which accepts either 0 or 7 for Sunday.
Member
There was a problem hiding this comment.
In fact, I think there could be some value in using DayOfWeek.from_value here. It implicitly handles domain errors.
Perhaps the parameter restriction should even be narrowed to DayOfWeek, instead of the union?
An enum value is more explicit than a plain number.
I realize that .week_date has union type restriction as well, so that would be a change.
straight-shoota
approved these changes
Apr 22, 2025
ysbaddaden
approved these changes
Apr 24, 2025
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This function returns a
Timeinstance using a given month, week of month, and day of week. It is similar to the existing.week_date, except the week number is relative to the given month, not the beginning of the given year (or the end of the previous year).Windows time zone transitions are specified in this manner, as are the
Mdates of POSIXTZstrings.