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

Support U+202F / NARROW NO-BREAK SPACE in input strings #3348

Closed
christophflick-toast opened this issue Feb 14, 2023 · 0 comments
Closed

Support U+202F / NARROW NO-BREAK SPACE in input strings #3348

christophflick-toast opened this issue Feb 14, 2023 · 0 comments

Comments

@christophflick-toast
Copy link

In JavaScript engines that implement unicode ICU 72, Date's toLocaleString function returns a "NARROW NO-BREAK SPACE" (U+202F) unicode character before 'AM/PM'.
Maybe also in other cases, but that's the one where I noticed it.
This leads to an error when used in date-fns parse function.

To reproduce:

  1. Go somewhere where date-fns is available in the console, such as https://date-fns.org/v2.29.3/docs/parse
  2. Run init() in the console and wait for confirmation
  3. Run the following code
const date = new Date()
const localeStr = date.toLocaleTimeString('en-US', {
      hour12: true,
      hour: 'numeric',
      minute: '2-digit'
})
_.parse(localeStr, 'h:mm a', new Date())

You will get Invalid Date.
But if you remove the space or enter a regular space, it's fine.

Related:

NodeJS change: nodejs/node#45068
Kind of related issue in the v8 chromium engine: https://bugs.chromium.org/p/v8/issues/detail?id=13490
"Normalization of spaces" issue: https://unicode-org.atlassian.net/browse/CLDR-14032

@christophflick-toast christophflick-toast closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant