Skip to content

Stage 2.7 review feedback: tweak the cases when rejecting in CalendarDateAdd #56

@sffc

Description

@sffc

I think non-Gregorian date arithmentic should throw in roughly the same situations as Gregorian date arithmetic.

A case that differs is in calendars with leap months (chinese, dangi, hebrew). Currently the spec says:

If calendarDate.[[MonthCode]] is a leap month that doesn't exist in the year, then:
i. If overflow is reject, throw a RangeError exception.

But, this is stricter than in Gregorian, which happily allows an ephemeral date to exist so long as it is then moved into a regular month:

// Error:
Temporal.PlainDate.from("2024-02-29").add({ years: 1 }, { overflow: "reject" })

// OK:
Temporal.PlainDate.from("2024-02-29").add({ years: 1, months: 1 }, { overflow: "reject" })

// Error:
Temporal.PlainDate.from("2024-02-29").add({ years: 1, days: 1 }, { overflow: "reject" })

I don't see why LeapYear-M05L-01 + { years: 1, months: 1 } should throw if it doesn't do that in Gregorian.

To fix this, simply remove that one RangeError. The one a few steps later will still trigger if the days are invalid.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions