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

Side by Side Diff: third_party/WebKit/Source/platform/DateComponents.cpp

Issue 2388303002: reflow comments in platform/ (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 static unsigned countDigits(const String& src, unsigned start) { 94 static unsigned countDigits(const String& src, unsigned start) {
95 unsigned index = start; 95 unsigned index = start;
96 for (; index < src.length(); ++index) { 96 for (; index < src.length(); ++index) {
97 if (!isASCIIDigit(src[index])) 97 if (!isASCIIDigit(src[index]))
98 break; 98 break;
99 } 99 }
100 return index - start; 100 return index - start;
101 } 101 }
102 102
103 // Very strict integer parser. Do not allow leading or trailing whitespace unlik e charactersToIntStrict(). 103 // Very strict integer parser. Do not allow leading or trailing whitespace
104 // unlike charactersToIntStrict().
104 static bool toInt(const String& src, 105 static bool toInt(const String& src,
105 unsigned parseStart, 106 unsigned parseStart,
106 unsigned parseLength, 107 unsigned parseLength,
107 int& out) { 108 int& out) {
108 if (parseStart + parseLength > src.length() || !parseLength) 109 if (parseStart + parseLength > src.length() || !parseLength)
109 return false; 110 return false;
110 int value = 0; 111 int value = 0;
111 unsigned current = parseStart; 112 unsigned current = parseStart;
112 unsigned end = current + parseLength; 113 unsigned end = current + parseLength;
113 114
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (year < DateComponents::minimumYear()) 170 if (year < DateComponents::minimumYear())
170 return false; 171 return false;
171 if (year < DateComponents::maximumYear()) 172 if (year < DateComponents::maximumYear())
172 return true; 173 return true;
173 if (month < maximumMonthInMaximumYear) 174 if (month < maximumMonthInMaximumYear)
174 return true; 175 return true;
175 if (monthDay < maximumDayInMaximumMonth) 176 if (monthDay < maximumDayInMaximumMonth)
176 return true; 177 return true;
177 if (monthDay > maximumDayInMaximumMonth) 178 if (monthDay > maximumDayInMaximumMonth)
178 return false; 179 return false;
179 // (year, month, monthDay) = (maximumYear, maximumMonthInMaximumYear, maximumD ayInMaximumMonth) 180 // (year, month, monthDay) =
181 // (maximumYear, maximumMonthInMaximumYear, maximumDayInMaximumMonth)
180 return !hour && !minute && !second && !millisecond; 182 return !hour && !minute && !second && !millisecond;
181 } 183 }
182 184
183 bool DateComponents::addDay(int dayDiff) { 185 bool DateComponents::addDay(int dayDiff) {
184 ASSERT(m_monthDay); 186 ASSERT(m_monthDay);
185 187
186 int day = m_monthDay + dayDiff; 188 int day = m_monthDay + dayDiff;
187 if (day > maxDayOfMonth(m_year, m_month)) { 189 if (day > maxDayOfMonth(m_year, m_month)) {
188 day = m_monthDay; 190 day = m_monthDay;
189 int year = m_year; 191 int year = m_year;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (!addDay(carry)) 278 if (!addDay(carry))
277 return false; 279 return false;
278 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, hour, minute, m_second, 280 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, hour, minute, m_second,
279 m_millisecond)) 281 m_millisecond))
280 return false; 282 return false;
281 m_minute = minute; 283 m_minute = minute;
282 m_hour = hour; 284 m_hour = hour;
283 return true; 285 return true;
284 } 286 }
285 287
286 // Parses a timezone part, and adjust year, month, monthDay, hour, minute, secon d, millisecond. 288 // Parses a timezone part, and adjust year, month, monthDay, hour, minute,
289 // second, millisecond.
287 bool DateComponents::parseTimeZone(const String& src, 290 bool DateComponents::parseTimeZone(const String& src,
288 unsigned start, 291 unsigned start,
289 unsigned& end) { 292 unsigned& end) {
290 if (start >= src.length()) 293 if (start >= src.length())
291 return false; 294 return false;
292 unsigned index = start; 295 unsigned index = start;
293 if (src[index] == 'Z') { 296 if (src[index] == 'Z') {
294 end = index + 1; 297 end = index + 1;
295 return true; 298 return true;
296 } 299 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 if (!setMillisecondsSinceEpochForDateInternal(ms)) 529 if (!setMillisecondsSinceEpochForDateInternal(ms))
527 return false; 530 return false;
528 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, 531 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute,
529 m_second, m_millisecond)) 532 m_second, m_millisecond))
530 return false; 533 return false;
531 m_type = DateTime; 534 m_type = DateTime;
532 return true; 535 return true;
533 } 536 }
534 537
535 bool DateComponents::setMillisecondsSinceEpochForDateTimeLocal(double ms) { 538 bool DateComponents::setMillisecondsSinceEpochForDateTimeLocal(double ms) {
536 // Internal representation of DateTimeLocal is the same as DateTime except m_t ype. 539 // Internal representation of DateTimeLocal is the same as DateTime except
540 // m_type.
537 if (!setMillisecondsSinceEpochForDateTime(ms)) 541 if (!setMillisecondsSinceEpochForDateTime(ms))
538 return false; 542 return false;
539 m_type = DateTimeLocal; 543 m_type = DateTimeLocal;
540 return true; 544 return true;
541 } 545 }
542 546
543 bool DateComponents::setMillisecondsSinceEpochForMonth(double ms) { 547 bool DateComponents::setMillisecondsSinceEpochForMonth(double ms) {
544 m_type = Invalid; 548 m_type = Invalid;
545 if (!std::isfinite(ms)) 549 if (!std::isfinite(ms))
546 return false; 550 return false;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 case Week: 712 case Week:
709 return String::format("%04d-W%02d", m_year, m_week); 713 return String::format("%04d-W%02d", m_year, m_week);
710 case Invalid: 714 case Invalid:
711 break; 715 break;
712 } 716 }
713 ASSERT_NOT_REACHED(); 717 ASSERT_NOT_REACHED();
714 return String("(Invalid DateComponents)"); 718 return String("(Invalid DateComponents)");
715 } 719 }
716 720
717 } // namespace blink 721 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/DateComponents.h ('k') | third_party/WebKit/Source/platform/Decimal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698