-
Notifications
You must be signed in to change notification settings - Fork 156
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
weekOfYear
/ yearOfWeek
is not clearly specified for non-ISO calendars
#2744
Comments
@justingrant This an interesting topic and needs to be thought of carefully to avoid implementation divergence. The current ISO week year standard is based on the Gregory calendar and there are no ISO standards for other calendars. As Temporal is in its latest stages with implementation on the horizon, it would be safer for the time being to throw an error for non Gregory calendars until such time a sound and permanent fix is developed. The concept of introducing the same algorithm as used by ISO for other calendar into Temporal sounds great and will require further discussion. Under such solution, for Islamic calendars, the first day of the week is Saturday which is the first day after the holy rest day of Friday. The Islamic world considers Saturday as first day of the week. So an ISO Hijri (Islamic) week calendar-like will always start on Saturday and the middle day of the week is Tuesday. This follows the same concept of the current ISO week calendar based on Gregory calendar which start on Monday, with Thursday being the middle day. |
As a follow up on my post above regarding the last 2 paragraphs regarding implementation of a Hijri ISO-like week calendar, this does not mean that the existing week day numbering system should be changed for a Hijri calendar. I.e. day 1 is Monday and such numbering should remain as it is only a reference number. This is similar to the concept of when a work day starts which could different in different countries and does not impact day numbering. |
This is exactly correct. Temporal is locale-neutral; its focus is on software calculations like determining the number of years or months or days between dates, adding a duration to a date, or ensuring that calculations work as expected across time zones and calendars. Any calculation that depends on knowing the locale (for example, determining the first day of the week) happens in Intl, not Temporal. I find it useful to think about two subtly different concepts involved with days of the week: *indexing*\ of days (e.g. 1 means Monday) and *determining the first day of the week*\ which is locale-sensitive, as nicely summarized by Wikipedia:
In ECMAScript, the calendar determines indexing (Temporal uses calendars' indexes as opaque indexes that don't have semantic meaning), while it's It's an interesting question of whether different calendars may want to use different indexes, for example 5 could mean Monday. FWIW, the I don't have an opinion about how other calendars should design this, but I think you're correct that treating the cc @sffc you may be interested in this thread. |
Not opposed to disabling these functions in non-ISO calendars. I think the case of the Islamic calendar is particularly interesting because the calendar system carries context on how weeks work. I wouldn't want to box us into a particular behavior until we think it through. Alternatively we can consider this to be in scope for https://github.com/tc39/proposal-intl-era-monthcode |
I don't think it makes sense to require an analogue of the ISO 8601 algorithm, because there very well might be other appropriate behavior for a particular calendar. Throwing is probably best, with second-best being indication by otherwise-invalid values such as So I think we want to
|
We talked about this in today's champions meeting. There is precedent for this: CalendarDateEra gives undefined if the calendar doesn't have eras. I'll prepare a change for this, that we can present in the February plenary. |
As part of investigating #2740, I noticed that
weekOfYear
andyearOfWeek
implementations in the polyfill all use the ISO calendar, meaning that they always return the ISO year, or one more or less than the ISO year. This is incorrect based on the spec text excerpted below.But the spec is also silent about how non-ISO calendars should implement these properties, specifically how to handle the weeks at start or end of year. This seems like an open invitation for implementations to diverge.
Should we add text that explains how to calculate these values? Should we require all calendars to use the same algorithm used for ISO? Should these methods throw for non-ISO calendars, because the whole point of these methods is to expose the ISO calendar's week-numbering algorithm?
The text was updated successfully, but these errors were encountered: