Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: src/dateparser.cc

Issue 1240093005: Fix check for a date with a 24th hour (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix testcases Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/date-parse.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/dateparser.h" 7 #include "src/dateparser.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 int& second = comp_[2]; 73 int& second = comp_[2];
74 int& millisecond = comp_[3]; 74 int& millisecond = comp_[3];
75 75
76 if (hour_offset_ != kNone) { 76 if (hour_offset_ != kNone) {
77 if (!IsHour12(hour)) return false; 77 if (!IsHour12(hour)) return false;
78 hour %= 12; 78 hour %= 12;
79 hour += hour_offset_; 79 hour += hour_offset_;
80 } 80 }
81 81
82 if (!IsHour(hour) || !IsMinute(minute) || 82 if (!IsHour(hour) || !IsMinute(minute) ||
83 !IsSecond(second) || !IsMillisecond(millisecond)) return false; 83 !IsSecond(second) || !IsMillisecond(millisecond)) {
84 if (hour == 24 && minute == 0 && second == 0 && millisecond == 0) {
rossberg 2015/07/22 09:48:57 Invert to (hour != 24 || minute != 0 || second !=
hichris123 2015/07/22 22:44:17 Done.
85 // A 24th hour is allowed if minutes, seconds, and milliseconds are 0
86 } else {
87 return false;
88 }
89 }
84 90
85 output->set(HOUR, Smi::FromInt(hour)); 91 output->set(HOUR, Smi::FromInt(hour));
86 output->set(MINUTE, Smi::FromInt(minute)); 92 output->set(MINUTE, Smi::FromInt(minute));
87 output->set(SECOND, Smi::FromInt(second)); 93 output->set(SECOND, Smi::FromInt(second));
88 output->set(MILLISECOND, Smi::FromInt(millisecond)); 94 output->set(MILLISECOND, Smi::FromInt(millisecond));
89 return true; 95 return true;
90 } 96 }
91 97
92 98
93 bool DateParser::TimeZoneComposer::Write(FixedArray* output) { 99 bool DateParser::TimeZoneComposer::Write(FixedArray* output) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 length--; 188 length--;
183 } while (length > 3); 189 } while (length > 3);
184 number /= factor; 190 number /= factor;
185 } 191 }
186 return number; 192 return number;
187 } 193 }
188 194
189 195
190 } // namespace internal 196 } // namespace internal
191 } // namespace v8 197 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/date-parse.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698