Commit ea056cbf authored by hichris123's avatar hichris123 Committed by Commit bot

Fix check for a date with a 24th hour

According to the ECMA spec, a 24th hour is allowed if the minutes, seconds, and milliseconds are all zero (i.e. it's midnight). Previously, we parsed the date correctly, however, we failed to account in all checks for the possibility of a 24th hour. This CL changes the check to allow a 24th hour if it's exactly midnight.

BUG=chromium:174609
LOG=Y

Review URL: https://codereview.chromium.org/1240093005

Cr-Commit-Position: refs/heads/master@{#29816}
parent a10e877c
......@@ -80,7 +80,12 @@ bool DateParser::TimeComposer::Write(FixedArray* output) {
}
if (!IsHour(hour) || !IsMinute(minute) ||
!IsSecond(second) || !IsMillisecond(millisecond)) return false;
!IsSecond(second) || !IsMillisecond(millisecond)) {
// A 24th hour is allowed if minutes, seconds, and milliseconds are 0
if (hour != 24 || minute != 0 || second != 0 || millisecond != 0) {
return false;
}
}
output->set(HOUR, Smi::FromInt(hour));
output->set(MINUTE, Smi::FromInt(minute));
......
......@@ -244,14 +244,22 @@ var testCasesES5Misc = [
['2000-01T08:00:00.001Z', 946713600001],
['2000-01T08:00:00.099Z', 946713600099],
['2000-01T08:00:00.999Z', 946713600999],
['2000-01T00:00:00.001-08:00', 946713600001]];
['2000-01T00:00:00.001-08:00', 946713600001],
['2000-01-01T24:00', 946771200000],
['2000-01-01T24:00:00', 946771200000],
['2000-01-01T24:00:00.000', 946771200000],
['2000-01-01T24:00:00.000Z', 946771200000]];
var testCasesES5MiscNegative = [
'2000-01-01TZ',
'2000-01-01T60Z',
'2000-01-01T60:60Z',
'2000-01-0108:00Z',
'2000-01-01T08Z'];
'2000-01-01T08Z',
'2000-01-01T24:01',
'2000-01-01T24:00:01',
'2000-01-01T24:00:00.001',
'2000-01-01T24:00:00.999Z'];
// Run all the tests.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment