Closed tmt96 closed 4 years ago
@tmt96 what is your node.js version?
I'm on Node 10. However, we want to use NumberFormat in React Native on Hermes engine (https://hermesengine.dev/), which does not implement the Intl API and thus requires polyfill
If it's helpful, I did reproduce the bug with Node 13.1
@pyrocat101 do we have any update for this bug?
@tmt96 Hey, sorry busy at work on weekdays. I will get to it this weekend!
@tmt96 It looks like a bug on Intl.js side.
The CreateDateTimeParts
implementation references Intl.NumberFormat
that you polyfilled:
This nf2
is called by FormatNumber
here: https://github.com/andyearnshaw/Intl.js/blob/4bd382c5df206f328b35ca23579904f603b84f0b/src/12.datetimeformat.js#L991
And this FormatNumber
incorrectly assumes that Intl.NumberFormat
is also polyfilled by Intl.DateTimeFormat
and calls into PartitionNumberPattern
, which is Intl.js internal implementation specific:
As for solutions, I think you can either use native Intl.DateTimeFormat
, or use patch this line here to call nf2.format(v)
:
Which package?
intl-unified-number-format
Describe the bug If I use both the
intl
andintl-unified-number-format
packages,Intl.DateTimeFormat
returns error.To Reproduce Steps to reproduce the behavior: Create a node project with index.js:
Expected behavior Console prints out the correctly format date '03/2016'
Actual behavior Console prints out error: