ecma402
ecma402 copied to clipboard
What does year: '18', era: '78' mean in Node 12's chinese-calendar formatToParts output?
@ptomato and I are running across interesting behavior for chinese/dangi calendars in Node 12 vs. Node 14. I assume it's related to #225 and/or #349? We could use some advice. Specifically:
- What do the
yearanderafields refer to in Node 12 output? Is there an easy formula to convert these values to an ISO year? - Is there any combination of options in Node 12 to get the
relatedYearin the output?
I'm asking because https://github.com/tc39/proposal-temporal/pull/1245 is adding proof-of-concept support for all ICU calendars and I'd prefer for that PR to work in Node 12 if possible. That PR depends on DateTimeFormat.formatToParts output to convert ISO dates to calendar dates and also (in a very hacky, poor-performing, not-for-production way-- but OK for proof-of-concept) for converting calendar dates to ISO.
Here's what @ptomato sees in node 12.16.1 (v8 7.8.279.23-node.31):
new Intl.DateTimeFormat('en-US-u-ca-chinese', { day: 'numeric', month: 'numeric', year: 'numeric', era: 'short', timeZone: 'UTC' }).formatToParts(new Date('2001-02-01T00:00Z'))
[
{ type: 'month', value: '1' },
{ type: 'literal', value: ' ' },
{ type: 'day', value: '9' },
{ type: 'literal', value: ', ' },
{ type: 'year', value: '18' },
{ type: 'literal', value: ' ' },
{ type: 'era', value: '78' }
]
Here's what I see in Node v14.4.0:
new Intl.DateTimeFormat('en-US-u-ca-chinese', { day: 'numeric', month: 'numeric', year: 'numeric', era: 'short', timeZone: 'UTC' }).formatToParts(new Date('2001-02-01T00:00Z'))
[
{ type: 'month', value: '1' },
{ type: 'literal', value: ' ' },
{ type: 'day', value: '9' },
{ type: 'literal', value: ', ' },
{ type: 'relatedYear', value: '2001' }
]
@FrankYFTang
not sure. I think what you saw in Node 12 is a bug.