| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d805d5a commit f63ae52
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.7', | ||
| 39 | + 'v8_embedder_string': '-node.8', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,7 +192,7 @@ DateParser::DateToken DateParser::DateStringTokenizer<CharType>::Scan() { | |||
| 192 | 192 | if (in_->Skip('+')) return DateToken::Symbol('+'); | |
| 193 | 193 | if (in_->Skip('.')) return DateToken::Symbol('.'); | |
| 194 | 194 | if (in_->Skip(')')) return DateToken::Symbol(')'); | |
| 195 | - if (in_->IsAsciiAlphaOrAbove()) { | ||
| 195 | + if (in_->IsAsciiAlphaOrAbove() && !in_->IsWhiteSpaceChar()) { | ||
| 196 | 196 | DCHECK_EQ(KeywordTable::kPrefixLength, 3); | |
| 197 | 197 | uint32_t buffer[3] = {0, 0, 0}; | |
| 198 | 198 | int length = in_->ReadWord(buffer, 3); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,8 @@ class DateParser : public AllStatic { | |||
| 91 | 91 | // Return word length. | |
| 92 | 92 | int ReadWord(uint32_t* prefix, int prefix_size) { | |
| 93 | 93 | int len; | |
| 94 | - for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) { | ||
| 94 | + for (len = 0; IsAsciiAlphaOrAbove() && !IsWhiteSpaceChar(); | ||
| 95 | + Next(), len++) { | ||
| 95 | 96 | if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_); | |
| 96 | 97 | } | |
| 97 | 98 | for (int i = len; i < prefix_size; i++) prefix[i] = 0; | |
@@ -115,6 +116,7 @@ class DateParser : public AllStatic { | |||
| 115 | 116 | bool IsEnd() const { return ch_ == 0; } | |
| 116 | 117 | bool IsAsciiDigit() const { return IsDecimalDigit(ch_); } | |
| 117 | 118 | bool IsAsciiAlphaOrAbove() const { return ch_ >= 'A'; } | |
| 119 | + bool IsWhiteSpaceChar() const { return IsWhiteSpace(ch_); } | ||
| 118 | 120 | bool IsAsciiSign() const { return ch_ == '+' || ch_ == '-'; } | |
| 119 | 121 | ||
| 120 | 122 | // Return 1 for '+' and -1 for '-'. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + // Copyright 2022 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // Test the new Date( date.toLocaleString("en-US")) is not invalid. | ||
| 6 | + // This is not guaranteed by the standard but many code use that to set the | ||
| 7 | + // timezone as suggested in | ||
| 8 | + // https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone | ||
| 9 | + | ||
| 10 | + let d = new Date(); | ||
| 11 | + | ||
| 12 | + // https://tc39.es/ecma262/#sec-todatestring | ||
| 13 | + // 21.4.4.41.4 ToDateString ( tv ) | ||
| 14 | + // 1. If tv is NaN, return "Invalid Date". | ||
| 15 | + let invalid = "Invalid Date"; | ||
| 16 | + let largestDiff = 25*60*60*1000; | ||
| 17 | + | ||
| 18 | + let garbage = new Date("garbage"); | ||
| 19 | + assertTrue(invalid == garbage); | ||
| 20 | + assertEquals(NaN, garbage.getTime()); | ||
| 21 | + | ||
| 22 | + let d1 = new Date(d.toLocaleString("en-US")); | ||
| 23 | + assertTrue(d1 != invalid); | ||
| 24 | + assertTrue(d1.getTime() != NaN); | ||
| 25 | + // The milliseconds are different between d1 and d. | ||
| 26 | + assertTrue(Math.abs(d1-d) < 1000); | ||
| 27 | + | ||
| 28 | + // Force a version of date string which have U+202f before AM | ||
| 29 | + let nnbsp_am = new Date("11/16/2022, 9:04:55\u202fAM"); | ||
| 30 | + assertTrue(nnbsp_am != invalid); | ||
| 31 | + assertTrue(nnbsp_am.getTime() != NaN); | ||
| 32 | + // Force a version of date string which have U+202f before PM | ||
| 33 | + let nnbsp_pm = new Date("11/16/2022, 9:04:55\u202fPM"); | ||
| 34 | + assertTrue(nnbsp_pm != invalid); | ||
| 35 | + assertTrue(nnbsp_pm.getTime() != NaN); | ||
| 36 | + | ||
| 37 | + let d2 = new Date(d.toLocaleString("en-US", {timeZone: "Asia/Taipei"})); | ||
| 38 | + assertTrue(d2 != invalid); | ||
| 39 | + assertTrue(d2.getTime() != NaN); | ||
| 40 | + // The differences should be within 25 hours. | ||
| 41 | + assertTrue(Math.abs(d2-d) < largestDiff); | ||
| 42 | + | ||
| 43 | + let d3 = new Date(d.toLocaleString("en-US", {timeZone: "Africa/Lusaka"})); | ||
| 44 | + assertTrue(d3 != invalid); | ||
| 45 | + assertTrue(d3.getTime() != NaN); | ||
| 46 | + // The differences should be within 25 hours. | ||
| 47 | + assertTrue(Math.abs(d3-d) < largestDiff); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments