-
Notifications
You must be signed in to change notification settings - Fork 160
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
Reconsider year-week support in light of implementation feedback #2405
Comments
cc @sffc |
I prefer, in order, 4, 3, and 1, and don't consider 2 worth doing. |
I prefer option 3. We should grow into option 4 but I'm not interested in holding up the proposal on this. We can do 3 now and 4 later. In ICU4X, we return a single struct with the week number and the "RelativeYear" (which is either current, previous, or next). https://unicode-org.github.io/icu4x-docs/doc/icu_calendar/week/struct.WeekOf.html Note that for era and eraYear, we also combine those into a single struct in ICU4X. https://unicode-org.github.io/icu4x-docs/doc/icu_calendar/types/struct.FormattableYear.html My preference would be for |
@pipobscure suggested I would just note that |
In the Temporal champions meeting of 2022-10-13 we agreed that we want to present option 3 for consensus in November, with (as Shane said) the name This would add a |
To be presented for consensus in the November/December TC39 meeting. This adds tests for a 'yearOfWeek' getter to PlainDate, PlainDateTime, and ZonedDateTime, for use alongside 'weekOfYear', and tests for a corresponding method to Calendar. The tests are basically the existing tests of 'weekOfYear' adapted. Temporal issue: tc39/proposal-temporal#2405
To be presented for consensus in the November/December TC39 meeting. This adds tests for a 'yearOfWeek' getter to PlainDate, PlainDateTime, and ZonedDateTime, for use alongside 'weekOfYear', and tests for a corresponding method to Calendar. The tests are basically the existing tests of 'weekOfYear' adapted. Temporal issue: tc39/proposal-temporal#2405
The rationale that we got from feedback during implementation is that it's not obvious that the weekOfYear may belong to a different "week calendar year" than the date's calendar year, which may lead to bugs like unwittingly presenting the date 2022-01-01 as being in week 52 of 2022 (it is actually in week 52 of 2021.) Additionally, the yearOfWeek isn't that straightforward to calculate unless you are already calculating the week number. Adds the following APIs: Temporal.PlainDate.yearOfWeek Temporal.PlainDateTime.yearOfWeek Temporal.ZonedDateTime.yearOfWeek Temporal.Calendar.yearOfWeek() and updates the ToISOWeekOfYear and CalendarDateWeekOfYear abstract ops to return a Record with [[Week]] and [[Year]] fields, instead of just a week number. Closes: #2405
The rationale that we got from feedback during implementation is that it's not obvious that the weekOfYear may belong to a different "week calendar year" than the date's calendar year, which may lead to bugs like unwittingly presenting the date 2022-01-01 as being in week 52 of 2022 (it is actually in week 52 of 2021.) Additionally, the yearOfWeek isn't that straightforward to calculate unless you are already calculating the week number. Adds the following APIs: Temporal.PlainDate.yearOfWeek Temporal.PlainDateTime.yearOfWeek Temporal.ZonedDateTime.yearOfWeek Temporal.Calendar.yearOfWeek() and updates the ToISOWeekOfYear and CalendarDateWeekOfYear abstract ops to return a Record with [[Week]] and [[Year]] fields, instead of just a week number. Closes: #2405
The rationale that we got from feedback during implementation is that it's not obvious that the weekOfYear may belong to a different "week calendar year" than the date's calendar year, which may lead to bugs like unwittingly presenting the date 2022-01-01 as being in week 52 of 2022 (it is actually in week 52 of 2021.) Additionally, the yearOfWeek isn't that straightforward to calculate unless you are already calculating the week number. Adds the following APIs: Temporal.PlainDate.yearOfWeek Temporal.PlainDateTime.yearOfWeek Temporal.ZonedDateTime.yearOfWeek Temporal.Calendar.yearOfWeek() and updates the ToISOWeekOfYear and CalendarDateWeekOfYear abstract ops to return a Record with [[Week]] and [[Year]] fields, instead of just a week number. Closes: #2405
To be presented for consensus in the November/December TC39 meeting. This adds tests for a 'yearOfWeek' getter to PlainDate, PlainDateTime, and ZonedDateTime, for use alongside 'weekOfYear', and tests for a corresponding method to Calendar. The tests are basically the existing tests of 'weekOfYear' adapted. Temporal issue: tc39/proposal-temporal#2405
To be presented for consensus in the November/December TC39 meeting. This adds tests for a 'yearOfWeek' getter to PlainDate, PlainDateTime, and ZonedDateTime, for use alongside 'weekOfYear', and tests for a corresponding method to Calendar. The tests are basically the existing tests of 'weekOfYear' adapted. Temporal issue: tc39/proposal-temporal#2405
In the discussion about specifying ISOWeekOfYear (#2378) it came up that our limited support for year-week numbers can lead to bugs.
For example,
Temporal.PlainDate.from('2022-01-01').weekOfYear
is 52; January 1 2022 is day 6 of week 52 of the week-year 2021, and in ISO year-week notation (which we decided was out of scope for Temporal) would be notated2021-W52-6
, and referred to as being in "ISO week 52 of 2021". The current way to obtain the week-year is to rewind the date to the previous Monday and get the year of that date, which is not obvious.Several options:
date.year
and include an example of how to calculate the week-year in the cookbook.date.year
as the week-year is too high, and remove theweekOfYear
API from Temporal, saving it for a following proposal. In the meantime, week numbers (and week-years in the few use cases where they are needed) can be calculated in userland. Include an example of how to do that in the cookbook.date.year
as the week-year is too high, and add aweekYear
accessor property to PlainDate, PlainDateTime, and ZonedDateTime, or even replace theweekOfYear
API with an API that returns both the week-year and the week number since even withweekYear
people could still mistakenly usedate.year
as the week-year. Save full year-week-day support for a following proposal.The text was updated successfully, but these errors were encountered: