[go: up one dir, main page]

Skip to content
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

What does year: '18', era: '78' mean in Node 12's chinese-calendar formatToParts output? #533

Open
justingrant opened this issue Jan 25, 2021 · 2 comments
Labels
Temporal Issues relating to Intl support in Temporal

Comments

@justingrant
Copy link
Contributor

@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 year and era fields 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 relatedYear in the output?

I'm asking because tc39/proposal-temporal#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' }
]
@sffc
Copy link
Contributor
sffc commented Jan 25, 2021

@FrankYFTang

@FrankYFTang
Copy link
Contributor

not sure. I think what you saw in Node 12 is a bug.

@sffc sffc added the Temporal Issues relating to Intl support in Temporal label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Temporal Issues relating to Intl support in Temporal
Projects
None yet
Development

No branches or pull requests

3 participants