-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add support for ISO calendar week to Time #6681
Add support for ISO calendar week to Time #6681
Conversation
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 didn't review the algorithm much, but this seems more than solid enough to be accepted for a first implementation. We can always sort out edge cases as they're discovered, if any.
needs a rebase after #6555. |
4b951bd
to
cd4303c
Compare
Rebased. |
426d229
to
beee7a6
Compare
3fb2581
to
f3f95ee
Compare
@straight-shoota Sorry, could you rebase again this on master so we can merge in a more tidy fashion? |
f3f95ee
to
887d346
Compare
Sure, done. But I'm not sure what it adds, it could just be fast forwarded. |
Thanks! A rebase will not leave a text reference to the PR. Squash or merge commit will. But is better to avoid long standing branch merged and keep the repo as thin as possible. |
This PR adds two methods to
Time
for handling ISO calendar week:Time#calendar_week
returns the year and week number. The year is important because calendar weeks don't match up with calendar years and the calendar week might actually be in a different year than the regular calendar year (returned by#year
).Time.week_date
creates aTime
instance from a week date specified by year, week number and day of week.It also adds directives
%G, %g, %V
which utilize these methods toTime::Format
.The algorithms for calculating the week number and back are completely annotated in code. They're based on the description on Wikipedia and the implementation in Go's stdlib but with a few improvements.
Closes #2533
Depends on #6555