Support Unicode White Spaces in ParseDate()

This commit is contained in:
Andy 2026-03-05 17:32:10 -08:00 • committed by OwnedByWuigi
commit 501a90aad3

View file

@ -36,6 +36,7 @@
#include "js/Conversions.h"
#include "js/Date.h"
#include "unicode/uchar.h"
#include "vm/DateTime.h"
#include "vm/GlobalObject.h"
#include "vm/Interpreter.h"
@ -962,6 +963,12 @@ ParseDate(const CharT* s, size_t length, ClippedTime* result)
int c = s[i];
i++;
// CLDR 42 has opened the door to whitespace,
// so let's normalize them all to standard spaces.
if (u_hasBinaryProperty(static_cast<UChar32>(c), UCHAR_WHITE_SPACE)) {
c = ' ';
}
// Spaces, ASCII control characters, and commas are ignored.
if (c <= ' ' || c == ',')
continue;
@ -998,6 +1005,11 @@ ParseDate(const CharT* s, size_t length, ClippedTime* result)
i++;
}
// CLDR 42 reprise.
if (u_hasBinaryProperty(static_cast<UChar32>(c), UCHAR_WHITE_SPACE)) {
c = ' ';
}
/*
* Allow TZA before the year, so 'Wed Nov 05 21:49:11 GMT-0800 1997'
* works.