0
new Intl.DateTimeFormat('zh-CN-u-ca-chinese', { dateStyle: 'full' }).format(1680537600000)

The above code outputs 0040闰0214 12:00 上午 in Firefox, 2023癸卯年闰二月十四星期二 in Chrome/node/deno, 2023癸卯年闰二月14星期二 in bun.

Why those outputs are so different? How can I produce a uniform output?

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
swwind
  • 123
  • 6
  • _“Why those outputs are so different?”_ — Because they are implementation-dependent. _“How can I produce a uniform output?”_ — By using some other internationalization library. Which of these outputs do you need? Is any of these outputs _wrong_? Why do you want a uniform output? – Sebastian Simon Feb 02 '23 at 14:03
  • The output date is not wrong, but the way to write chinese calendars is wrong, such as we are using `癸卯年` but not `0040` to refer a year name (like `Friday` instead of `5`). I'll give up using `Intl` for generate date strings and rely on other libraries. Thank you for replying. – swwind Feb 02 '23 at 15:02
  • Your firefox distribution might be an older version of [icu4c](https://github.com/unicode-org/icu/releases/tag/release-72-1) – Oluwafemi Sule Feb 02 '23 at 16:53

0 Answers0