Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Date parse should accept narrow-no-break-space
https://bugs.webkit.org/show_bug.cgi?id=247986 rdar://102427399 Reviewed by Alexey Shvayka. After ICU 72, CLDR generates narrow-no-break-space for date time output. So, `new Date().toLocaleString('en-US')` starts generating a string including narrow-no-break-space instead of simple spaces. However since code in the wild assumes `new Date(new Date().toLocaleString('en-US'))` works, we need to maintain the ability to parse string including narrowNoBreakSpaces. Rough consensus among implementaters (V8, SpiderMonkey, and us) is replacing narrowNoBreakSpaces with simple spaces before parsing. * JSTests/complex.yaml: * JSTests/complex/date-parse-with-narrow-no-break-space.js: Added. (shouldBe): * Source/JavaScriptCore/runtime/JSDateMath.cpp: (JSC::DateCache::parseDate): * Source/WTF/wtf/unicode/CharacterNames.h: Canonical link: https://commits.webkit.org/256754@main
- Loading branch information
1 parent
c388572
commit a8f967cd42c5add143939660b7cd928375182377
Showing
4 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
var space = ' '; | ||
var narrowNoBreakSpace = '\u202f'; | ||
|
||
shouldBe(new Date(`11/16/2022, 10:33:58${space}AM`).getTime(), 1668623638000); | ||
shouldBe(new Date(`11/16/2022, 10:33:58${narrowNoBreakSpace}AM`).getTime(), 1668623638000); | ||
shouldBe(Date.parse(`11/16/2022, 10:33:58${space}AM`), 1668623638000); | ||
shouldBe(Date.parse(`11/16/2022, 10:33:58${narrowNoBreakSpace}AM`), 1668623638000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters