-
Notifications
You must be signed in to change notification settings - Fork 153
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
How to find first day of year (or month) in a non-ISO calendar? #1220
Comments
The way to support this would be to allow months and years in the round method. You said in #827:
I think month and year rounding is a tractable problem to pass through the calendar. The calendar could have a function |
As pointed at #1203, I would suggest to require the month to be a number, possibly with a supplemental field like monthType to solve the problem of lunisolar calendars. AND it would be required from the author to set the beginning of the year to the first day and the first (common) month ,i.e. (1, 1). If necessary we could say: authors, please provide a |
Preliminary thoughts, going through the range of the various lunisolar calendars: The traditional Hebrew calendar inserts a second Adar month (called Adar I) right before Adar (which is called Adar II in a leap year). Adar II is when the normal Adar festivals get celebrated. Here, the leap month occurs before the "real" month. The traditional Chinese and Korean lunisolar calendars will insert leap months when they do not overlap with a "solar term" (and thus can be inserted near any month). These months share the name of the previous month. Here, the leap month occurs after the "real" month. It's unclear to me what happens to festivals, I believe they follow the "real" month. It's also unclear to me if there is a special qualifier. The Hindu vedic lunisolar calendar (which is not in CLDR, and has multiple variants) is similar, but it goes a step further. If a month occurs without a zodiac transit, it is declared to be a leap month sharing the name of the succeeding month (but with a qualifier, it's basically called "Extra Foo" vs "Foo" or "Regular Foo"). Here, the leap month occurs before the "real" month. Festivals follow the "real" month. The reason the Hindu calendar is more complex is that if multiple zodiac transits occur in a month (very rare), then the following month will be deleted. So it's crucial that whatever implementation we have has the ability to arbitrarily reject month-year combos if we ever wish to be able to support these calendars. The Thai Buddhist lunisolar calendar (also not in CLDR) works similarly to the Hebrew calendar where leap months occur at a defined time in the year, though I am unclear about their naming. I am unaware of any lunisolar calendar which gives the leap month an entirely different name. In the Hindu vedic lunisolar calendar it is common to just call the month "Extra Month", but the month's actual name is "Extra Foo". If such a calendar crops up we can always support it with something like This means that the constraints are:
Putting all this together, A separate |
Hi @Manishearth - Welcome to Temporal! It's great to have more Googlers helping out. Also good to see a fellow Berkeleyan here! Over in #1203 and #1231, I proposed (with a proof-of-concept implementation in #1245) that we solve the lunisolar month-numbering dilemma by offering two ways of describing the month:
@sffc and I have been discussing which of these two fields should be called In an earlier design of #1245, in addition to If you have more feedback or ideas about month properties, feel free to chime in over in #1203. #1245 also has a list of other non-ISO-calendar issues that you may also be interested in. |
The only one I know is the Roman antique lunisolar calendar, just before Julius Caesar turned it into the Julian (solar) calendar, the ancestor of the Gregorian calendar. The leap month was called Mercedonius or Intercalaris. It was inserted after Feb. 24th. |
So I just realized that there's another wrinkle which as far as I can tell, has not yet been brought up in this group. Japanese eras may start mid-year: > new Date("2019-04-31").toLocaleString('en-US-u-ca-japanese', {era: 'short'})
"4/30/31 Heisei, 5:00:00 PM"
> new Date("2020-05-31").toLocaleString('en-US-u-ca-japanese', {era: 'short'})
"5/30/2 Reiwa, 5:00:00 PM"
> new Date("2020-01-02").toLocaleString('en-US-u-ca-japanese', {era: 'short'})
"1/1/2 Reiwa, 4:00:00 PM" This means:
Furthermore, while Reiwa started on May 1 2019, eras can begin in the middle of a month (and from what I can tell, most do -- e.g. the first day of Jōkyō was February 21). In this model, This pushes me closer to the belief that month indexing should either not be exposed, or exposed via This also evinces a subtler problem: day-of-the-month numbering isn't indexing either! "The first day of February Jōkyō 1" is February 21, not "February 1, Jōkyō 1" (an invalid date). I think it's fine to keep treating day-of-the-month numbering as day-of-the-month numbering (i.e. (We may also have similar issues if we ever decide to handle hybrid calendars like the julian-gregorian switchover of various countries) |
Reacting to the issue raised by @Manishearth:
and
In the case of Japanese calendar (which is the Julian-Gregorian calendar with a specific year numbering system), IMHO we should simply say that the month and the year remain the same when a new era opens. In other words, the first day of Reiwa era falls in month 5. In fact, I am sure that "the first day of February Jõkyõ 1" would be solved that way: either it did not exist, or it was in the former era. In the same way, the first day of the first week of 2020 was in fact in 30 Dec. 2019, and the last day of the last week of 2020 was last sunday, i.e. 3 Jan. 2021. I hope a Japanese person can confirm this. As for hybrid European calendars that have a switchover, let me show you how this works after designing a class of calendar, with the switching date as parameter. A very interesting (and real !) case is this of several German protestant states, who decided to switch to Gregorian on 1700-03-01. On https://louis-aime.github.io/Temporal-experiences/TemporalEnvironment.html, We may also discuss weeks, but I do not believe this is a real issue. People did not count weeks the way ISO does. |
Great discussion! There are (at least) three cases where days are skipped by calendars.
Here's a proposal for how to handle these cases. Some of below may already be implemented in the polyfill and/or in #1245. Feedback appreciated!
date = Temporal.PlainDate.from({ eraYear: -5, era: 'ad', month: 1, day: 1, calendar: 'gregory' });
=> -000005-01-01[c=gregory]
({ era, eraYear, year } = date)
// => { era: "bc", eraYear: 6, year: -5 }
date = Temporal.PlainDate.from({ eraYear: 1, era: 'reiwa', month: 1, day: 1, calendar: 'japanese' });
=> 2019-01-01[c=japanese]
({ era, eraYear, year } = date)
// => { era: "heisei", eraYear: 31, year: 152 } LMK if there are concerns about this proposed behavior. If not, I'll fix the broken parts of (2) and implement (1) in #1245. |
I do have some thoughts about |
IMO, the rules @justingrant proposes sounds good. I think there should not be valuable opposition. Exceptional cultural practises should be handled apart, e.g. with additional custom methods. As an example, the Christian feast of Annunciation is on March 25, but may be reported to a much later date if it falls near Eater. Such rules should not "pollute" Temporal's general behaviour. I am sure calendars' authors can understand this. |
Assuming we have a month index property, then this is solved, I think? |
Yep, first day of year is trivial if we have a month index field that can be used in |
As per the consensus at the 2021-01-19 meeting, we do have that, so closing this. |
How will a developer find the first day of a year in a non-ISO calendar? In ISO this is easy, e.g.
date.with({ month: 1, day: 1 })
.But per #1203, what if month and day can't be guaranteed to be numeric? And what if the first month of the year isn't guaranteed to be
1
? The same questions apply to first-day-of-month use cases too.One possible fix (other than specifying that all calendars must have numeric months and dates that start with
1
) would be to add astartOfYear()
andstartOfMonth()
method.BTW, this issue came up as part of building code examples for #1203.
The text was updated successfully, but these errors were encountered: