OLD | NEW |
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 return false; | 459 return false; |
460 ++index; | 460 ++index; |
461 if (!parseTime(src, index, end)) | 461 if (!parseTime(src, index, end)) |
462 return false; | 462 return false; |
463 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_s
econd, m_millisecond)) | 463 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_s
econd, m_millisecond)) |
464 return false; | 464 return false; |
465 m_type = DateTimeLocal; | 465 m_type = DateTimeLocal; |
466 return true; | 466 return true; |
467 } | 467 } |
468 | 468 |
469 bool DateComponents::parseDateTime(const String& src, unsigned start, unsigned&
end) | |
470 { | |
471 unsigned index; | |
472 if (!parseDate(src, start, index)) | |
473 return false; | |
474 if (index >= src.length()) | |
475 return false; | |
476 if (src[index] != 'T') | |
477 return false; | |
478 ++index; | |
479 if (!parseTime(src, index, index)) | |
480 return false; | |
481 if (!parseTimeZone(src, index, end)) | |
482 return false; | |
483 if (!withinHTMLDateLimits(m_year, m_month, m_monthDay, m_hour, m_minute, m_s
econd, m_millisecond)) | |
484 return false; | |
485 m_type = DateTime; | |
486 return true; | |
487 } | |
488 | |
489 static inline double positiveFmod(double value, double divider) | 469 static inline double positiveFmod(double value, double divider) |
490 { | 470 { |
491 double remainder = fmod(value, divider); | 471 double remainder = fmod(value, divider); |
492 return remainder < 0 ? remainder + divider : remainder; | 472 return remainder < 0 ? remainder + divider : remainder; |
493 } | 473 } |
494 | 474 |
495 void DateComponents::setMillisecondsSinceMidnightInternal(double msInDay) | 475 void DateComponents::setMillisecondsSinceMidnightInternal(double msInDay) |
496 { | 476 { |
497 ASSERT(msInDay >= 0 && msInDay < msPerDay); | 477 ASSERT(msInDay >= 0 && msInDay < msPerDay); |
498 m_millisecond = static_cast<int>(fmod(msInDay, msPerSecond)); | 478 m_millisecond = static_cast<int>(fmod(msInDay, msPerSecond)); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 case Week: | 699 case Week: |
720 return String::format("%04d-W%02d", m_year, m_week); | 700 return String::format("%04d-W%02d", m_year, m_week); |
721 case Invalid: | 701 case Invalid: |
722 break; | 702 break; |
723 } | 703 } |
724 ASSERT_NOT_REACHED(); | 704 ASSERT_NOT_REACHED(); |
725 return String("(Invalid DateComponents)"); | 705 return String("(Invalid DateComponents)"); |
726 } | 706 } |
727 | 707 |
728 } // namespace blink | 708 } // namespace blink |
OLD | NEW |