-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Error Date.toLocaleString() in node 19.0.0 #45171
Comments
NARROW NO-BREAK SPACE sounds like it's from the CLDR 42 change in ICU 72.1
except Node.js 19.0.0 doesn't ship with ICU 72.1 as that only landed on |
Another possibility is that you are using a Node.js linked against your system version of ICU, and that version was updated to 72.1. |
Looks like a bug in v8. It's set up to handle unicode whitespace, but instead treats them as keywords. I created https://bugs.chromium.org/p/v8/issues/detail?id=13490 |
seems like user error not a bug, don't assume that Localized date format is parseable by Date. Looking at the v8 issue, I can see where there is a coding bug on the V8 side, and I haven't looked at the spec yet. But that said, I still disagree that the original example code here should always pass… It makes an invalid assumption about the US date format Do not use a localized date format if you expect it to be machine readable! |
The spec is here: https://tc39.es/ecma262/#sec-date.parse It specifically says:
and:
I don't know if there's a more canonical reference for what implementation-defined strings v8 supports other than this comment in its source: It does seem more of a coincidence that In general though, if you want guaranteed-to-work round-trip date formatting and parsing, then you would want to use the ISO 8601 format given by |
This was fixed upstream: |
FWIW change LGTM |
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: nodejs#45171
I just want to leave a note that |
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: nodejs#45171
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: #45171 PR-URL: #45573 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: #45171 PR-URL: #45573 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: #45171 PR-URL: #45573 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Hi, It seems working on 19.0
gives
But not on latest/19.1
fails with
Then it seems fixed and re-broken ? |
It was never an issue in official 19.0.x releases. It was broken in 19.1.0 when Node switched to ICU 72. It is subsequently fixed in 19.2.0 which cherry-picked the v8 commit that fixes it. The original report here of it breaking against 19.0.0 must have been linking against an external ICU which was ICU 72. |
Unfortunately, it's a default way to change the timezone for the date https://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript and many libraries use it. |
the stack overflow answer is a misuse of toLocaleString.
|
@srl295 indeed, but I don't know a better way now. A very popular library like dayjs uses it. Will be good to provide a better solution and add it to stack overflow. |
Original commit message: [intl] Enhance Date parser to take Unicode SPACE This is needed to prepare for the landing of ICU72. Allow U+202F in the Date String, which the toLocaleString("en-US") will generate w/ ICU72. Bug: v8:13494 Change-Id: I41b83c4094ce3d0737a72dcd6310b52c68fdcdca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4027341 Reviewed-by: Yang Guo <[email protected]> Reviewed-by: Jungshik Shin <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#84308} Refs: v8/v8@2ada52c Fixes: #45171 PR-URL: #45573 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
related: nodejs/node#46123 related: nodejs/node#45171
…Format components on SFC template and JSX/TSX (#1310) * fix: support type inference of Translation, NumberFormat and DatetimeFormat components on SFC template and JSX/TSX * fix: timezone setting * fix: pinned node v18 minor version * fix * fix: disalbe node v18 related: nodejs/node#46123 related: nodejs/node#45171
…nt-1290833591 until patched in node 18
* Update template path * fix use of template * clean up variables * Regression test updates * Fix node version of integration tests * Fix regression testing machine pool * Fix uses of fs.rmSync for Node 12 compatibility * Do not limit the max parallel runs * rush change * Fix regression integration test on Mac and Windows * fix issues with the params passed to removeSync * fix lint rules * Only run regression on 12.x as 12.22 is the latest minor version * set timeout to an hr, run appui tests in node12, ?? not added til node14 * hacky fix for https://github.com/nodejs/node/issues/45171\#issuecomment-1290833591 until patched in node 18 * rush change * fix more tests * rush change * use || because ?? not supported til node14. again --------- Co-authored-by: Arun George <[email protected]>
Version
19.0.0
Platform
Linux 6.0.2-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 15 Oct 2022 14:00:51 +0000 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Stability
What is the expected behavior?
No response
What do you see instead?
Error Date.toLocaleString(): NARROW NO-BREAK SPACE (U+202f) without last whitespace
Additional information
Thanks for node) It`s cool)
The text was updated successfully, but these errors were encountered: