Skip to content

CalendarDateToISO: Constrain behaviour for regnal years? #2865

@anba

Description

@anba

It'd be nice to have some more detailed information how constraining should work for regnal years in the Japanese calendar.

  1. Dates before the start of the era (from SpiderMonkey WIP implementation):
js> Temporal.PlainDate.from({calendar: "japanese", era: "reiwa", eraYear: 1, month: 1, day: 1}).toString()
"2019-05-01[u-ca=japanese]"
js> Temporal.PlainDate.from({calendar: "japanese", era: "reiwa", eraYear: 1, month: 1, day: 1}).era
"reiwa"
js> Temporal.PlainDate.from({calendar: "japanese", era: "reiwa", eraYear: 1, month: 1, day: 1}, {overflow: "reject"}).toString()
typein:1:20 RangeError: calendar field "eraYear" is too large: 1

Whereas the spec polyfill changes to the previous era (for both constrain and reject overflow behaviour):

js> Temporal.PlainDate.from({calendar: "japanese", era: "reiwa", eraYear: 1, month: 1, day: 1}).toString()
"2019-01-01[u-ca=japanese]"
js> Temporal.PlainDate.from({calendar: "japanese", era: "reiwa", eraYear: 1, month: 1, day: 1}).era       
"heisei"
  1. Dates after the end of the era (from SpiderMonkey WIP implementation):
js> Temporal.PlainDate.from({calendar: "japanese", era: "heisei", eraYear: 100, month: 1, day: 1}).toString()
"2019-04-30[u-ca=japanese]"
js> Temporal.PlainDate.from({calendar: "japanese", era: "heisei", eraYear: 100, month: 1, day: 1}).era
"heisei"
js> Temporal.PlainDate.from({calendar: "japanese", era: "heisei", eraYear: 100, month: 1, day: 1}, {overflow: "reject"}).toString()
typein:1:20 RangeError: calendar field "eraYear" is too large: 100

Spec polyfill has (for both constrain and reject overflow behaviour):

js> Temporal.PlainDate.from({calendar: "japanese", era: "heisei", eraYear: 100, month: 1, day: 1}).toString()
"2088-01-01[u-ca=japanese]"
js> Temporal.PlainDate.from({calendar: "japanese", era: "heisei", eraYear: 100, month: 1, day: 1}).era       
"reiwa"

Questions I've asked myself:

  • Does overflow behaviour affect era/eraYear?
  • If yes, does constrain overflow constrain to the start/end of the era?
  • If yes, does reject overflow reject dates before/after the era?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions