[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:31:10 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 28e187047eac59eb8d2859b088d3ab8eee2257e0
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 28 16:47:04 2010 +0000

    2010-01-28  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Rename ISODateTime.{cpp,h} to DateComponents.{cpp,h}
            https://bugs.webkit.org/show_bug.cgi?id=34245
    
            No functional changes.
    
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * html/DateComponents.cpp: Copied from WebCore/html/ISODateTime.cpp.
            (WebCore::DateComponents::maxWeekNumberInYear):
            (WebCore::DateComponents::parseYear):
            (WebCore::DateComponents::addDay):
            (WebCore::DateComponents::addMinute):
            (WebCore::DateComponents::parseTimeZone):
            (WebCore::DateComponents::parseMonth):
            (WebCore::DateComponents::parseDate):
            (WebCore::DateComponents::parseWeek):
            (WebCore::DateComponents::parseTime):
            (WebCore::DateComponents::parseDateTimeLocal):
            (WebCore::DateComponents::parseDateTime):
            (WebCore::DateComponents::setMillisecondsSinceMidnightInternal):
            (WebCore::DateComponents::setMillisecondsSinceEpochForDateInternal):
            (WebCore::DateComponents::setMillisecondsSinceEpochForDate):
            (WebCore::DateComponents::setMillisecondsSinceEpochForDateTime):
            (WebCore::DateComponents::setMillisecondsSinceEpochForDateTimeLocal):
            (WebCore::DateComponents::setMillisecondsSinceEpochForMonth):
            (WebCore::DateComponents::setMillisecondsSinceMidnight):
            (WebCore::DateComponents::setMillisecondsSinceEpochForWeek):
            (WebCore::DateComponents::millisecondsSinceEpochForTime):
            (WebCore::DateComponents::millisecondsSinceEpoch):
            (WebCore::DateComponents::toStringForTime):
            (WebCore::DateComponents::toString):
            * html/DateComponents.h: Copied from WebCore/html/ISODateTime.h.
            (WebCore::DateComponents::DateComponents):
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::parseToDouble):
            (WebCore::HTMLInputElement::valueAsDate):
            (WebCore::HTMLInputElement::setValueAsDate):
            (WebCore::HTMLInputElement::setValueAsNumber):
            (WebCore::HTMLInputElement::formStringToDateComponents):
            * html/HTMLInputElement.h:
            * html/ISODateTime.cpp: Removed.
            * html/ISODateTime.h: Removed.
            * html/ValidityState.cpp:
            (WebCore::ValidityState::typeMismatch):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54003 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 442b9e9..6273adf 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,55 @@
+2010-01-28  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Rename ISODateTime.{cpp,h} to DateComponents.{cpp,h}
+        https://bugs.webkit.org/show_bug.cgi?id=34245
+
+        No functional changes.
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/DateComponents.cpp: Copied from WebCore/html/ISODateTime.cpp.
+        (WebCore::DateComponents::maxWeekNumberInYear):
+        (WebCore::DateComponents::parseYear):
+        (WebCore::DateComponents::addDay):
+        (WebCore::DateComponents::addMinute):
+        (WebCore::DateComponents::parseTimeZone):
+        (WebCore::DateComponents::parseMonth):
+        (WebCore::DateComponents::parseDate):
+        (WebCore::DateComponents::parseWeek):
+        (WebCore::DateComponents::parseTime):
+        (WebCore::DateComponents::parseDateTimeLocal):
+        (WebCore::DateComponents::parseDateTime):
+        (WebCore::DateComponents::setMillisecondsSinceMidnightInternal):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDateInternal):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDate):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDateTime):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForDateTimeLocal):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForMonth):
+        (WebCore::DateComponents::setMillisecondsSinceMidnight):
+        (WebCore::DateComponents::setMillisecondsSinceEpochForWeek):
+        (WebCore::DateComponents::millisecondsSinceEpochForTime):
+        (WebCore::DateComponents::millisecondsSinceEpoch):
+        (WebCore::DateComponents::toStringForTime):
+        (WebCore::DateComponents::toString):
+        * html/DateComponents.h: Copied from WebCore/html/ISODateTime.h.
+        (WebCore::DateComponents::DateComponents):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseToDouble):
+        (WebCore::HTMLInputElement::valueAsDate):
+        (WebCore::HTMLInputElement::setValueAsDate):
+        (WebCore::HTMLInputElement::setValueAsNumber):
+        (WebCore::HTMLInputElement::formStringToDateComponents):
+        * html/HTMLInputElement.h:
+        * html/ISODateTime.cpp: Removed.
+        * html/ISODateTime.h: Removed.
+        * html/ValidityState.cpp:
+        (WebCore::ValidityState::typeMismatch):
+
 2010-01-28  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 22bf78e..89fb66e 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -980,6 +980,8 @@ webcore_sources += \
 	WebCore/html/DataGridColumnList.cpp \
 	WebCore/html/DataGridColumnList.h \
 	WebCore/html/DataGridDataSource.h \
+	WebCore/html/DateComponents.cpp \
+	WebCore/html/DateComponents.h \
 	WebCore/html/DOMDataGridDataSource.cpp \
 	WebCore/html/DOMDataGridDataSource.h \
 	WebCore/html/File.cpp \
@@ -1151,8 +1153,6 @@ webcore_sources += \
 	WebCore/html/HTMLUListElement.h \
 	WebCore/html/HTMLViewSourceDocument.cpp \
 	WebCore/html/HTMLViewSourceDocument.h \
-	WebCore/html/ISODateTime.cpp \
-	WebCore/html/ISODateTime.h \
 	WebCore/html/ImageData.cpp \
 	WebCore/html/ImageData.h \
 	WebCore/html/MediaError.h \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 57e186f..57611cd 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1371,6 +1371,8 @@
             'html/DOMDataGridDataSource.h',
             'html/DataGridColumnList.cpp',
             'html/DataGridColumnList.h',
+            'html/DateComponents.cpp',
+            'html/DateComponents.h',
             'html/File.cpp',
             'html/File.h',
             'html/FileList.cpp',
@@ -1547,8 +1549,6 @@
             'html/HTMLVideoElement.h',
             'html/HTMLViewSourceDocument.cpp',
             'html/HTMLViewSourceDocument.h',
-            'html/ISODateTime.cpp',
-            'html/ISODateTime.h',
             'html/ImageData.cpp',
             'html/ImageData.h',
             'html/MediaError.h',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 7f630ed..959f783 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -569,6 +569,7 @@ SOURCES += \
     html/CollectionCache.cpp \
     html/DataGridColumn.cpp \
     html/DataGridColumnList.cpp \
+    html/DateComponents.cpp \
     html/DOMDataGridDataSource.cpp \
     html/File.cpp \
     html/FileList.cpp \
@@ -654,7 +655,6 @@ SOURCES += \
     html/HTMLTokenizer.cpp \
     html/HTMLUListElement.cpp \
     html/HTMLViewSourceDocument.cpp \
-    html/ISODateTime.cpp \
     html/ImageData.cpp \
     html/PreloadScanner.cpp \
     html/ValidityState.cpp \
@@ -1254,6 +1254,7 @@ HEADERS += \
     html/CollectionCache.h \
     html/DataGridColumn.h \
     html/DataGridColumnList.h \
+    html/DateComponents.h \
     html/DOMDataGridDataSource.h \
     html/File.h \
     html/FileList.h \
@@ -1343,7 +1344,6 @@ HEADERS += \
     html/HTMLUListElement.h \
     html/HTMLVideoElement.h \
     html/HTMLViewSourceDocument.h \
-    html/ISODateTime.h \
     html/ImageData.h \
     html/PreloadScanner.h \
     html/TimeRanges.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index bfd59da..12cca99 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -29877,6 +29877,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\html\DateComponents.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\html\DateComponents.h"
+				>
+			</File>
+			<File
 				RelativePath="..\html\DOMDataGridDataSource.cpp"
 				>
 			</File>
@@ -34073,14 +34081,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\html\ISODateTime.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\html\ISODateTime.h"
-				>
-			</File>
-			<File
 				RelativePath="..\html\MediaError.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index da41f8b..147809d 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4812,8 +4812,8 @@
 		F5C041E50FFCA96D00839D4A /* DOMHTMLDataListElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C041E00FFCA96D00839D4A /* DOMHTMLDataListElementInternal.h */; };
 		F5C041E60FFCA96D00839D4A /* JSHTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041E10FFCA96D00839D4A /* JSHTMLDataListElement.cpp */; };
 		F5C041E70FFCA96D00839D4A /* JSHTMLDataListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C041E20FFCA96D00839D4A /* JSHTMLDataListElement.h */; };
-		F5D3A57C106B83B300545297 /* ISODateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5D3A57A106B83B300545297 /* ISODateTime.cpp */; };
-		F5D3A57D106B83B300545297 /* ISODateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D3A57B106B83B300545297 /* ISODateTime.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		F5D3A57C106B83B300545297 /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5D3A57A106B83B300545297 /* DateComponents.cpp */; };
+		F5D3A57D106B83B300545297 /* DateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D3A57B106B83B300545297 /* DateComponents.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F916C48D0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F916C48B0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp */; };
 		F916C48E0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F916C48C0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h */; };
 		F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */; };
@@ -10113,8 +10113,8 @@
 		F5C2869302846DCD018635CA /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
 		F5C2869402846DCD018635CA /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
 		F5C2869502846DCD018635CA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
-		F5D3A57A106B83B300545297 /* ISODateTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISODateTime.cpp; sourceTree = "<group>"; };
-		F5D3A57B106B83B300545297 /* ISODateTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISODateTime.h; sourceTree = "<group>"; };
+		F5D3A57A106B83B300545297 /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = "<group>"; };
+		F5D3A57B106B83B300545297 /* DateComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateComponents.h; sourceTree = "<group>"; };
 		F8216299029F4FB501000131 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		F916C48B0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLHttpRequestProgressEvent.cpp; sourceTree = "<group>"; };
 		F916C48C0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequestProgressEvent.h; sourceTree = "<group>"; };
@@ -12737,6 +12737,8 @@
 				BC77CFAB0FF173D30070887B /* DataGridColumnList.h */,
 				BC77CF980FF172420070887B /* DataGridColumnList.idl */,
 				BCBCAE360FF19385000762AE /* DataGridDataSource.h */,
+				F5D3A57A106B83B300545297 /* DateComponents.cpp */,
+				F5D3A57B106B83B300545297 /* DateComponents.h */,
 				BC7DAAEC0FF9615D00CE0138 /* DOMDataGridDataSource.cpp */,
 				BC7DAAED0FF9615D00CE0138 /* DOMDataGridDataSource.h */,
 				BCDBB8CC0E08958400C60FF6 /* File.cpp */,
@@ -12992,8 +12994,6 @@
 				E446139A0CD6331000FADA75 /* HTMLVideoElement.idl */,
 				BCCD74E40A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp */,
 				BCCD74DB0A4C8D35005FDA6D /* HTMLViewSourceDocument.h */,
-				F5D3A57A106B83B300545297 /* ISODateTime.cpp */,
-				F5D3A57B106B83B300545297 /* ISODateTime.h */,
 				A77979130D6B9D0C003851B9 /* ImageData.cpp */,
 				A77979140D6B9D0C003851B9 /* ImageData.h */,
 				A77979150D6B9D0C003851B9 /* ImageData.idl */,
@@ -16235,6 +16235,7 @@
 				BC77CFAC0FF173D30070887B /* DataGridColumnList.h in Headers */,
 				BCBCAE370FF19385000762AE /* DataGridDataSource.h in Headers */,
 				BC22746F0E83664500E7F975 /* DataRef.h in Headers */,
+				F5D3A57D106B83B300545297 /* DateComponents.h in Headers */,
 				4162A451101145AE00DFF3ED /* DedicatedWorkerContext.h in Headers */,
 				41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */,
 				4167EBF6102962BA003D252A /* DefaultSharedWorkerRepository.h in Headers */,
@@ -17190,7 +17191,6 @@
 				BCCD74DC0A4C8D35005FDA6D /* HTMLViewSourceDocument.h in Headers */,
 				514C76710CE923A1007EF3CD /* HTTPHeaderMap.h in Headers */,
 				514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
-				F5D3A57D106B83B300545297 /* ISODateTime.h in Headers */,
 				B275356E0B053814002CE64F /* Icon.h in Headers */,
 				5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
 				51E1ECBE0C91C90400DC255B /* IconDatabaseClient.h in Headers */,
@@ -18894,6 +18894,7 @@
 				1AD51A150CB59CD300953D11 /* DatabaseTracker.cpp in Sources */,
 				BC77D2390FF298080070887B /* DataGridColumn.cpp in Sources */,
 				BC77D1FD0FF28D9B0070887B /* DataGridColumnList.cpp in Sources */,
+				F5D3A57C106B83B300545297 /* DateComponents.cpp in Sources */,
 				4162A450101145AE00DFF3ED /* DedicatedWorkerContext.cpp in Sources */,
 				41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */,
 				4167EBF5102962BA003D252A /* DefaultSharedWorkerRepository.cpp in Sources */,
@@ -19381,7 +19382,6 @@
 				BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */,
 				0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */,
 				514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
-				F5D3A57C106B83B300545297 /* ISODateTime.cpp in Sources */,
 				5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
 				445C8DB710015FC90031531A /* IconDatabaseNone.cpp in Sources */,
 				1A2D753E0DE47FAB00F0A648 /* IconFetcher.cpp in Sources */,
diff --git a/WebCore/html/DateComponents.cpp b/WebCore/html/DateComponents.cpp
new file mode 100644
index 0000000..c272002
--- /dev/null
+++ b/WebCore/html/DateComponents.cpp
@@ -0,0 +1,654 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DateComponents.h"
+
+#include "PlatformString.h"
+#include <limits.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/DateMath.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+// The oldest day of Gregorian Calendar is 1582-10-15. We don't support dates older than it.
+static const int gregorianStartYear = 1582;
+static const int gregorianStartMonth = 9; // This is October, since months are 0 based.
+static const int gregorianStartDay = 15;
+
+static const int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+static bool isLeapYear(int year)
+{
+    if (year % 4)
+        return false;
+    if (!(year % 400))
+        return true;
+    if (!(year % 100))
+        return false;
+    return true;
+}
+
+// 'month' is 0-based.
+static int maxDayOfMonth(int year, int month)
+{
+    if (month != 1) // February?
+        return daysInMonth[month];
+    return isLeapYear(year) ? 29 : 28;
+}
+
+// 'month' is 0-based.
+static int dayOfWeek(int year, int month, int day)
+{
+    int shiftedMonth = month + 2;
+    // 2:January, 3:Feburuary, 4:March, ...
+
+    // Zeller's congruence
+    if (shiftedMonth <= 3) {
+        shiftedMonth += 12;
+        year--;
+    }
+    // 4:March, ..., 14:January, 15:February
+
+    int highYear = year / 100;
+    int lowYear = year % 100;
+    // We add 6 to make the result Sunday-origin.
+    int result = (day + 13 * shiftedMonth / 5 + lowYear + lowYear / 4 + highYear / 4 + 5 * highYear + 6) % 7;
+    return result;
+}
+
+int DateComponents::maxWeekNumberInYear() const
+{
+    int day = dayOfWeek(m_year, 0, 1); // January 1.
+    return day == Thursday || (day == Wednesday && isLeapYear(m_year)) ? 53 : 52;
+}
+
+static unsigned countDigits(const UChar* src, unsigned length, unsigned start)
+{
+    unsigned index = start;
+    for (; index < length; ++index) {
+        if (!isASCIIDigit(src[index]))
+            break;
+    }
+    return index - start;
+}
+
+// Very strict integer parser. Do not allow leading or trailing whitespace unlike charactersToIntStrict().
+static bool toInt(const UChar* src, unsigned length, unsigned parseStart, unsigned parseLength, int& out)
+{
+    if (parseStart + parseLength > length || parseLength <= 0)
+        return false;
+    int value = 0;
+    const UChar* current = src + parseStart;
+    const UChar* end = current + parseLength;
+
+    // We don't need to handle negative numbers for ISO 8601.
+    for (; current < end; ++current) {
+        if (!isASCIIDigit(*current))
+            return false;
+        int digit = *current - '0';
+        if (value > (INT_MAX - digit) / 10) // Check for overflow.
+            return false;
+        value = value * 10 + digit;
+    }
+    out = value;
+    return true;
+}
+
+bool DateComponents::parseYear(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    unsigned digitsLength = countDigits(src, length, start);
+    // Needs at least 4 digits according to the standard.
+    if (digitsLength < 4)
+        return false;
+    int year;
+    if (!toInt(src, length, start, digitsLength, year))
+        return false;
+    // No support for years before Gregorian calendar.
+    if (year < gregorianStartYear)
+        return false;
+    m_year = year;
+    end = start + digitsLength;
+    return true;
+}
+
+static bool beforeGregorianStartDate(int year, int month, int monthDay)
+{
+    return year < gregorianStartYear
+        || year == gregorianStartYear && month < gregorianStartMonth
+        || year == gregorianStartYear && month == gregorianStartMonth && monthDay < gregorianStartDay;
+}
+
+bool DateComponents::addDay(int dayDiff)
+{
+    ASSERT(m_monthDay);
+
+    int day = m_monthDay + dayDiff;
+    if (day > maxDayOfMonth(m_year, m_month)) {
+        day = m_monthDay;
+        int year = m_year;
+        int month = m_month;
+        int maxDay = maxDayOfMonth(year, month);
+        for (; dayDiff > 0; --dayDiff) {
+            ++day;
+            if (day > maxDay) {
+                day = 1;
+                ++month;
+                if (month >= 12) { // month is 0-origin.
+                    month = 0;
+                    ++year;
+                    if (year < 0) // Check for overflow.
+                        return false;
+                }
+                maxDay = maxDayOfMonth(year, month);
+            }
+        }
+        m_year = year;
+        m_month = month;
+    } else if (day < 1) {
+        int month = m_month;
+        int year = m_year;
+        day = m_monthDay;
+        for (; dayDiff < 0; ++dayDiff) {
+            --day;
+            if (day < 1) {
+                --month;
+                if (month < 0) {
+                    month = 11;
+                    --year;
+                }
+                day = maxDayOfMonth(year, month);
+            }
+            if (beforeGregorianStartDate(year, month, day))
+                return false;
+        }
+        m_year = year;
+        m_month = month;
+    }
+    m_monthDay = day;
+    return true;
+}
+
+bool DateComponents::addMinute(int minute)
+{
+    int carry;
+    // min can be negative or greater than 59.
+    minute += m_minute;
+    if (minute > 59) {
+        carry = minute / 60;
+        minute = minute % 60;
+    } else if (m_minute < 0) {
+        carry = (59 - m_minute) / 60;
+        minute += carry * 60;
+        carry = -carry;
+        ASSERT(minute >= 0 && minute <= 59);
+    } else {
+        m_minute = minute;
+        return true;
+    }
+
+    int hour = m_hour + carry;
+    if (hour > 23) {
+        carry = hour / 24;
+        hour = hour % 24;
+    } else if (hour < 0) {
+        carry = (23 - hour) / 24;
+        hour += carry * 24;
+        carry = -carry;
+        ASSERT(hour >= 0 && hour <= 23);
+    } else {
+        m_minute = minute;
+        m_hour = hour;
+        return true;
+    }
+    if (!addDay(carry))
+        return false;
+    m_minute = minute;
+    m_hour = hour;
+    return true;
+}
+
+// Parses a timezone part, and adjust year, month, monthDay, hour, minute, second, millisecond.
+bool DateComponents::parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    if (start >= length)
+        return false;
+    unsigned index = start;
+    if (src[index] == 'Z') {
+        end = index + 1;
+        return true;
+    }
+
+    bool minus;
+    if (src[index] == '+')
+        minus = false;
+    else if (src[index] == '-')
+        minus = true;
+    else
+        return false;
+    ++index;
+
+    int hour;
+    int minute;
+    if (!toInt(src, length, index, 2, hour) || hour < 0 || hour > 23)
+        return false;
+    index += 2;
+
+    if (index >= length || src[index] != ':')
+        return false;
+    ++index;
+
+    if (!toInt(src, length, index, 2, minute) || minute < 0 || minute > 59)
+        return false;
+    index += 2;
+
+    if (minus) {
+        hour = -hour;
+        minute = -minute;
+    }
+
+    // Subtract the timezone offset.
+    if (!addMinute(-(hour * 60 + minute)))
+        return false;
+    end = index;
+    return true;
+}
+
+bool DateComponents::parseMonth(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    unsigned index;
+    if (!parseYear(src, length, start, index))
+        return false;
+    if (index >= length || src[index] != '-')
+        return false;
+    ++index;
+
+    int month;
+    if (!toInt(src, length, index, 2, month) || month < 1 || month > 12)
+        return false;
+    --month;
+    // No support for months before Gregorian calendar.
+    if (beforeGregorianStartDate(m_year, month, gregorianStartDay))
+        return false;
+    m_month = month;
+    end = index + 2;
+    m_type = Month;
+    return true;
+}
+
+bool DateComponents::parseDate(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    unsigned index;
+    if (!parseMonth(src, length, start, index))
+        return false;
+    // '-' and 2-digits are needed.
+    if (index + 2 >= length)
+        return false;
+    if (src[index] != '-')
+        return false;
+    ++index;
+
+    int day;
+    if (!toInt(src, length, index, 2, day) || day < 1 || day > maxDayOfMonth(m_year, m_month))
+        return false;
+    // No support for dates before Gregorian calendar.
+    if (m_year == gregorianStartYear && m_month == gregorianStartMonth && day < gregorianStartDay)
+        return false;
+    m_monthDay = day;
+    end = index + 2;
+    m_type = Date;
+    return true;
+}
+
+bool DateComponents::parseWeek(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    unsigned index;
+    if (!parseYear(src, length, start, index))
+        return false;
+
+    // 4 characters ('-' 'W' digit digit) are needed.
+    if (index + 3 >= length)
+        return false;
+    if (src[index] != '-')
+        return false;
+    ++index;
+    if (src[index] != 'W')
+        return false;
+    ++index;
+
+    int week;
+    if (!toInt(src, length, index, 2, week) || week < 1 || week > maxWeekNumberInYear())
+        return false;
+    // No support for years older than or equals to Gregorian calendar start year.
+    if (m_year <= gregorianStartYear)
+        return false;
+    m_week = week;
+    end = index + 2;
+    m_type = Week;
+    return true;
+}
+
+bool DateComponents::parseTime(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    int hour;
+    if (!toInt(src, length, start, 2, hour) || hour < 0 || hour > 23)
+        return false;
+    unsigned index = start + 2;
+    if (index >= length)
+        return false;
+    if (src[index] != ':')
+        return false;
+    ++index;
+
+    int minute;
+    if (!toInt(src, length, index, 2, minute) || minute < 0 || minute > 59)
+        return false;
+    index += 2;
+
+    int second = 0;
+    int millisecond = 0;
+    // Optional second part.
+    // Do not return with false because the part is optional.
+    if (index + 2 < length && src[index] == ':') {
+        if (toInt(src, length, index + 1, 2, second) && second >= 0 && second <= 59) {
+            index += 3;
+
+            // Optional fractional second part.
+            if (index < length && src[index] == '.') {
+                unsigned digitsLength = countDigits(src, length, index + 1);
+                if (digitsLength >  0) {
+                    ++index;
+                    bool ok;
+                    if (digitsLength == 1) {
+                        ok = toInt(src, length, index, 1, millisecond);
+                        millisecond *= 100;
+                    } else if (digitsLength == 2) {
+                        ok = toInt(src, length, index, 2, millisecond);
+                        millisecond *= 10;
+                    } else // digitsLength >= 3
+                        ok = toInt(src, length, index, 3, millisecond);
+                    ASSERT(ok);
+                    index += digitsLength;
+                }
+            }
+        }
+    }
+    m_hour = hour;
+    m_minute = minute;
+    m_second = second;
+    m_millisecond = millisecond;
+    end = index;
+    m_type = Time;
+    return true;
+}
+
+bool DateComponents::parseDateTimeLocal(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    unsigned index;
+    if (!parseDate(src, length, start, index))
+        return false;
+    if (index >= length)
+        return false;
+    if (src[index] != 'T')
+        return false;
+    ++index;
+    if (!parseTime(src, length, index, end))
+        return false;
+    m_type = DateTimeLocal;
+    return true;
+}
+
+bool DateComponents::parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end)
+{
+    ASSERT(src);
+    unsigned index;
+    if (!parseDate(src, length, start, index))
+        return false;
+    if (index >= length)
+        return false;
+    if (src[index] != 'T')
+        return false;
+    ++index;
+    if (!parseTime(src, length, index, index))
+        return false;
+    if (!parseTimeZone(src, length, index, end))
+        return false;
+    m_type = DateTime;
+    return true;
+}
+
+static inline double positiveFmod(double value, double divider)
+{
+    double remainder = fmod(value, divider);
+    return remainder < 0 ? remainder + divider : remainder;
+}
+
+void DateComponents::setMillisecondsSinceMidnightInternal(double msInDay)
+{
+    ASSERT(msInDay >= 0 && msInDay < msPerDay);
+    m_millisecond = static_cast<int>(fmod(msInDay, msPerSecond));
+    double value = floor(msInDay / msPerSecond);
+    m_second = static_cast<int>(fmod(value, secondsPerMinute));
+    value = floor(value / secondsPerMinute);
+    m_minute = static_cast<int>(fmod(value, minutesPerHour));
+    m_hour = static_cast<int>(value / minutesPerHour);
+}
+
+bool DateComponents::setMillisecondsSinceEpochForDateInternal(double ms)
+{
+    m_year = msToYear(ms);
+    int yearDay = dayInYear(ms, m_year);
+    m_month = monthFromDayInYear(yearDay, isLeapYear(m_year));
+    m_monthDay = dayInMonthFromDayInYear(yearDay, isLeapYear(m_year));
+    return true;
+}
+
+bool DateComponents::setMillisecondsSinceEpochForDate(double ms)
+{
+    m_type = Invalid;
+    if (!isfinite(ms))
+        return false;
+    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
+        return false;
+    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
+        return false;
+    m_type = Date;
+    return true;
+}
+
+bool DateComponents::setMillisecondsSinceEpochForDateTime(double ms)
+{
+    m_type = Invalid;
+    if (!isfinite(ms))
+        return false;
+    ms = round(ms);
+    setMillisecondsSinceMidnightInternal(positiveFmod(ms, msPerDay));
+    if (!setMillisecondsSinceEpochForDateInternal(ms))
+        return false;
+    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
+        return false;
+    m_type = DateTime;
+    return true;
+}
+
+bool DateComponents::setMillisecondsSinceEpochForDateTimeLocal(double ms)
+{
+    // Internal representation of DateTimeLocal is the same as DateTime except m_type.
+    if (!setMillisecondsSinceEpochForDateTime(ms))
+        return false;
+    m_type = DateTimeLocal;
+    return true;
+}
+
+bool DateComponents::setMillisecondsSinceEpochForMonth(double ms)
+{
+    m_type = Invalid;
+    if (!isfinite(ms))
+        return false;
+    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
+        return false;
+    // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal().
+    if (beforeGregorianStartDate(m_year, m_month, gregorianStartDay))
+        return false;
+    m_type = Month;
+    return true;
+}
+
+bool DateComponents::setMillisecondsSinceMidnight(double ms)
+{
+    m_type = Invalid;
+    if (!isfinite(ms))
+        return false;
+    setMillisecondsSinceMidnightInternal(positiveFmod(round(ms), msPerDay));
+    m_type = Time;
+    return true;
+}
+
+// Offset from January 1st to Monday of the ISO 8601's first week.
+//   ex. If January 1st is Friday, such Monday is 3 days later. Returns 3.
+static int offsetTo1stWeekStart(int year)
+{
+    int offsetTo1stWeekStart = 1 - dayOfWeek(year, 0, 1);
+    if (offsetTo1stWeekStart <= -4)
+        offsetTo1stWeekStart += 7;
+    return offsetTo1stWeekStart;
+}
+
+bool DateComponents::setMillisecondsSinceEpochForWeek(double ms)
+{
+    m_type = Invalid;
+    if (!isfinite(ms))
+        return false;
+    ms = round(ms);
+
+    m_year = msToYear(ms);
+    // We don't support gregorianStartYear. Week numbers are undefined in that year.
+    if (m_year <= gregorianStartYear)
+        return false;
+
+    int yearDay = dayInYear(ms, m_year);
+    int offset = offsetTo1stWeekStart(m_year);
+    if (yearDay < offset) {
+        // The day belongs to the last week of the previous year.
+        m_year--;
+        if (m_year <= gregorianStartYear)
+            return false;
+        m_week = maxWeekNumberInYear();
+    } else {
+        m_week = ((yearDay - offset) / 7) + 1;
+        if (m_week > maxWeekNumberInYear()) {
+            m_year++;
+            m_week = 1;
+        }
+    }
+    m_type = Week;
+    return true;
+}
+
+double DateComponents::millisecondsSinceEpochForTime() const
+{
+    ASSERT(m_type == Time || m_type == DateTime || m_type == DateTimeLocal);
+    return ((m_hour * minutesPerHour + m_minute) * secondsPerMinute + m_second) * msPerSecond + m_millisecond;
+}
+
+double DateComponents::millisecondsSinceEpoch() const
+{
+    switch (m_type) {
+    case Date:
+        return dateToDaysFrom1970(m_year, m_month, m_monthDay) * msPerDay;
+    case DateTime:
+    case DateTimeLocal:
+        return dateToDaysFrom1970(m_year, m_month, m_monthDay) * msPerDay + millisecondsSinceEpochForTime();
+    case Month:
+        return dateToDaysFrom1970(m_year, m_month, 1) * msPerDay;
+    case Time:
+        return millisecondsSinceEpochForTime();
+    case Week:
+        return (dateToDaysFrom1970(m_year, 0, 1) + offsetTo1stWeekStart(m_year) + (m_week - 1) * 7) * msPerDay;
+    case Invalid:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return invalidMilliseconds();
+}
+
+String DateComponents::toStringForTime(SecondFormat format) const
+{
+    ASSERT(m_type == DateTime || m_type == DateTimeLocal || m_type == Time);
+    SecondFormat effectiveFormat = format;
+    if (m_millisecond)
+        effectiveFormat = Millisecond;
+    else if (format == None && m_second)
+        effectiveFormat = Second;
+
+    switch (effectiveFormat) {
+    default:
+        ASSERT_NOT_REACHED();
+        // Fallback to None.
+    case None:
+        return String::format("%02d:%02d", m_hour, m_minute);
+    case Second:
+        return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second);
+    case Millisecond:
+        return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond);
+    }
+}
+
+String DateComponents::toString(SecondFormat format) const
+{
+    switch (m_type) {
+    case Date:
+        return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
+    case DateTime:
+        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
+            + toStringForTime(format) + String("Z");
+    case DateTimeLocal:
+        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
+            + toStringForTime(format);
+    case Month:
+        return String::format("%04d-%02d", m_year, m_month + 1);
+    case Time:
+        return toStringForTime(format);
+    case Week:
+        return String::format("%04d-W%02d", m_year, m_week);
+    case Invalid:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return String("(Invalid DateComponents)");
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/DateComponents.h b/WebCore/html/DateComponents.h
new file mode 100644
index 0000000..7e4ff7b
--- /dev/null
+++ b/WebCore/html/DateComponents.h
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DateComponents_h
+#define DateComponents_h
+
+#include <limits>
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+class String;
+
+// A DateComponents instance represents one of the following date and time combinations:
+// * Month type: year-month
+// * Date type: year-month-day
+// * Week type: year-week
+// * Time type: hour-minute-second-millisecond
+// * DateTime or DateTimeLocal type: year-month-day hour-minute-second-millisecond
+class DateComponents {
+public:
+    DateComponents()
+        : m_millisecond(0)
+        , m_second(0)
+        , m_minute(0)
+        , m_hour(0)
+        , m_monthDay(0)
+        , m_month(0)
+        , m_year(0)
+        , m_week(0)
+        , m_type(Invalid)
+    {
+    }
+
+    int millisecond() const { return m_millisecond; }
+    int second() const { return m_second; }
+    int minute() const { return m_minute; }
+    int hour() const { return m_hour; }
+    int monthDay() const { return m_monthDay; }
+    int month() const { return m_month; }
+    int fullYear() const { return m_year; }
+    int week() const { return m_week; }
+
+    enum SecondFormat {
+        None, // Suppress the second part and the millisecond part if they are 0.
+        Second, // Always show the second part, and suppress the millisecond part if it is 0.
+        Millisecond // Always show the second part and the millisecond part.
+    };
+
+    // Returns an ISO 8601 representation for this instance.
+    // The format argument is valid for DateTime, DateTimeLocal, and Time types.
+    String toString(SecondFormat format = None) const;
+
+    // parse*() and setMillisecondsSince*() functions are initializers for an
+    // DateComponents instance. If these functions return false, the instance
+    // might be invalid.
+
+    // The following six functions parse the input 'src' whose length is
+    // 'length', and updates some fields of this instance. The parsing starts at
+    // src[start] and examines characters before src[length].
+    // 'src' must be non-null. The 'src' string doesn't need to be
+    // null-terminated.
+    // The functions return true if the parsing succeeds, and set 'end' to the
+    // next index after the last consumed. Extra leading characters cause parse
+    // failures, and the trailing extra characters don't cause parse failures.
+
+    // Sets year and month.
+    bool parseMonth(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Sets year, month and monthDay.
+    bool parseDate(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Sets year and week.
+    bool parseWeek(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Sets hour, minute, second and millisecond.
+    bool parseTime(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Sets year, month, monthDay, hour, minute, second and millisecond.
+    bool parseDateTimeLocal(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Sets year, month, monthDay, hour, minute, second and millisecond, and adjusts timezone.
+    bool parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end);
+
+    // The following setMillisecondsSinceEpochFor*() functions take
+    // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as
+    // the argument, and update all fields for the corresponding
+    // DateComponents type. The functions return true if it succeeds, and
+    // false if they fail.
+
+    // For Date type. Updates m_year, m_month and m_monthDay.
+    bool setMillisecondsSinceEpochForDate(double ms);
+    // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
+    bool setMillisecondsSinceEpochForDateTime(double ms);
+    // For DateTimeLocal type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
+    bool setMillisecondsSinceEpochForDateTimeLocal(double ms);
+    // For Month type. Updates m_year and m_month.
+    bool setMillisecondsSinceEpochForMonth(double ms);
+    // For Week type. Updates m_year and m_week.
+    bool setMillisecondsSinceEpochForWeek(double ms);
+
+    // For Time type. Updates m_hour, m_minute, m_second and m_millisecond.
+    bool setMillisecondsSinceMidnight(double ms);
+
+    // Returns the number of milliseconds from 1970-01-01 00:00:00 UTC.
+    // For a DateComponents initialized with parseDateTimeLocal(),
+    // millisecondsSinceEpoch() returns a value for UTC timezone.
+    double millisecondsSinceEpoch() const;
+    static inline double invalidMilliseconds() { return std::numeric_limits<double>::quiet_NaN(); }
+
+private:
+    // Returns the maximum week number in this DateComponents's year.
+    // The result is either of 52 and 53.
+    int maxWeekNumberInYear() const;
+    bool parseYear(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    bool addDay(int);
+    bool addMinute(int);
+    bool parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end);
+    // Helper for millisecondsSinceEpoch().
+    double millisecondsSinceEpochForTime() const;
+    // Helpers for setMillisecondsSinceEpochFor*().
+    bool setMillisecondsSinceEpochForDateInternal(double ms);
+    void setMillisecondsSinceMidnightInternal(double ms);
+    // Helper for toString().
+    String toStringForTime(SecondFormat) const;
+
+    // m_weekDay values
+    enum {
+        Sunday = 0,
+        Monday,
+        Tuesday,
+        Wednesday,
+        Thursday,
+        Friday,
+        Saturday,
+    };
+
+    int m_millisecond; // 0 - 999
+    int m_second;
+    int m_minute;
+    int m_hour;
+    int m_monthDay; // 1 - 31
+    int m_month; // 0:January - 11:December
+    int m_year; //  1582 -
+    int m_week; // 1 - 53
+
+    enum Type {
+        Invalid,
+        Date,
+        DateTime,
+        DateTimeLocal,
+        Month,
+        Time,
+        Week,
+    };
+    Type m_type;
+};
+
+
+} // namespace WebCore
+
+#endif // DateComponents_h
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 52a75be..43ec943 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -29,6 +29,7 @@
 #include "AXObjectCache.h"
 #include "CSSPropertyNames.h"
 #include "ChromeClient.h"
+#include "DateComponents.h"
 #include "Document.h"
 #include "Editor.h"
 #include "Event.h"
@@ -45,7 +46,6 @@
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
-#include "ISODateTime.h"
 #include "ScriptEventListener.h"
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
@@ -1492,10 +1492,10 @@ double HTMLInputElement::parseToDouble(const String& src, double defaultValue) c
     case MONTH:
     case TIME:
     case WEEK: {
-        ISODateTime dateTime;
-        if (!formStringToISODateTime(inputType(), src, &dateTime))
+        DateComponents date;
+        if (!formStringToDateComponents(inputType(), src, &date))
             return defaultValue;
-        double msec = dateTime.millisecondsSinceEpoch();
+        double msec = date.millisecondsSinceEpoch();
         ASSERT(isfinite(msec));
         return msec;
     }
@@ -1538,7 +1538,7 @@ double HTMLInputElement::valueAsDate() const
     case MONTH:
     case TIME:
     case WEEK:
-        return parseToDouble(value(), ISODateTime::invalidMilliseconds());
+        return parseToDouble(value(), DateComponents::invalidMilliseconds());
 
     case BUTTON:
     case CHECKBOX:
@@ -1559,31 +1559,31 @@ double HTMLInputElement::valueAsDate() const
     case TELEPHONE:
     case TEXT:
     case URL:
-        return ISODateTime::invalidMilliseconds();
+        return DateComponents::invalidMilliseconds();
     }
     ASSERT_NOT_REACHED();
-    return ISODateTime::invalidMilliseconds();
+    return DateComponents::invalidMilliseconds();
 }
 
 void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
 {
-    ISODateTime dateTime;
+    DateComponents date;
     bool success;
     switch (inputType()) {
     case DATE:
-        success = dateTime.setMillisecondsSinceEpochForDate(value);
+        success = date.setMillisecondsSinceEpochForDate(value);
         break;
     case DATETIME:
-        success = dateTime.setMillisecondsSinceEpochForDateTime(value);
+        success = date.setMillisecondsSinceEpochForDateTime(value);
         break;
     case MONTH:
-        success = dateTime.setMillisecondsSinceEpochForMonth(value);
+        success = date.setMillisecondsSinceEpochForMonth(value);
         break;
     case TIME:
-        success = dateTime.setMillisecondsSinceMidnight(value);
+        success = date.setMillisecondsSinceMidnight(value);
         break;
     case WEEK:
-        success = dateTime.setMillisecondsSinceEpochForWeek(value);
+        success = date.setMillisecondsSinceEpochForWeek(value);
         break;
     case BUTTON:
     case CHECKBOX:
@@ -1617,7 +1617,7 @@ void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
     // FIXME: We should specify SecondFormat.
     // e.g. If the step value is 60, use SecondFormat::None.
     //      If the step value is 1, use SecondFormat::Second.
-    setValue(dateTime.toString());
+    setValue(date.toString());
 }
 
 double HTMLInputElement::valueAsNumber() const
@@ -1671,15 +1671,15 @@ void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec)
         setValueAsDate(newValue, ec);
         return;
     case DATETIMELOCAL: {
-        ISODateTime dateTime;
-        if (!dateTime.setMillisecondsSinceEpochForDateTimeLocal(newValue)) {
+        DateComponents date;
+        if (!date.setMillisecondsSinceEpochForDateTimeLocal(newValue)) {
             setValue(String());
             return;
         }
         // FIXME: We should specify SecondFormat.
         // e.g. If the step value is 60, use SecondFormat::None.
         //      If the step value is 1, use SecondFormat::Second.
-        setValue(dateTime.toString());
+        setValue(date.toString());
         return;
     }
     case NUMBER:
@@ -2448,11 +2448,11 @@ bool HTMLInputElement::formStringToDouble(const String& src, double* out)
     return true;
 }
 
-bool HTMLInputElement::formStringToISODateTime(InputType type, const String& formString, ISODateTime* out)
+bool HTMLInputElement::formStringToDateComponents(InputType type, const String& formString, DateComponents* out)
 {
     if (formString.isEmpty())
         return false;
-    ISODateTime ignoredResult;
+    DateComponents ignoredResult;
     if (!out)
         out = &ignoredResult;
     const UChar* characters = formString.characters();
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 8e20e75..f35a1b1 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -30,11 +30,11 @@
 
 namespace WebCore {
 
+class DateComponents;
 class FileList;
 class HTMLDataListElement;
 class HTMLImageLoader;
 class HTMLOptionElement;
-class ISODateTime;
 class KURL;
 class VisibleSelection;
 
@@ -267,9 +267,9 @@ public:
     // HTML5's "algorithm to convert a number to a string" for NUMBER/RANGE types.
     static String formStringFromDouble(double);
     // Parses the specified string as the InputType, and returns true if it is successfully parsed.
-    // An instance pointed by the ISODateTime* parameter will have parsed values and be
-    // modified even if the parsing fails.  The ISODateTime* parameter may be 0.
-    static bool formStringToISODateTime(InputType, const String&, ISODateTime*);
+    // An instance pointed by the DateComponents* parameter will have parsed values and be
+    // modified even if the parsing fails.  The DateComponents* parameter may be 0.
+    static bool formStringToDateComponents(InputType, const String&, DateComponents*);
     
 protected:
     virtual void willMoveToNewOwnerDocument();
diff --git a/WebCore/html/ISODateTime.cpp b/WebCore/html/ISODateTime.cpp
deleted file mode 100644
index 3ed3007..0000000
--- a/WebCore/html/ISODateTime.cpp
+++ /dev/null
@@ -1,654 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ISODateTime.h"
-
-#include "PlatformString.h"
-#include <limits.h>
-#include <wtf/ASCIICType.h>
-#include <wtf/DateMath.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-// The oldest day of Gregorian Calendar is 1582-10-15. We don't support dates older than it.
-static const int gregorianStartYear = 1582;
-static const int gregorianStartMonth = 9; // This is October, since months are 0 based.
-static const int gregorianStartDay = 15;
-
-static const int daysInMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-static bool isLeapYear(int year)
-{
-    if (year % 4)
-        return false;
-    if (!(year % 400))
-        return true;
-    if (!(year % 100))
-        return false;
-    return true;
-}
-
-// `month' is 0-based.
-static int maxDayOfMonth(int year, int month)
-{
-    if (month != 1) // February?
-        return daysInMonth[month];
-    return isLeapYear(year) ? 29 : 28;
-}
-
-// `month' is 0-based.
-static int dayOfWeek(int year, int month, int day)
-{
-    int shiftedMonth = month + 2;
-    // 2:January, 3:Feburuary, 4:March, ...
-
-    // Zeller's congruence
-    if (shiftedMonth <= 3) {
-        shiftedMonth += 12;
-        year--;
-    }
-    // 4:March, ..., 14:January, 15:February
-
-    int highYear = year / 100;
-    int lowYear = year % 100;
-    // We add 6 to make the result Sunday-origin.
-    int result = (day + 13 * shiftedMonth / 5 + lowYear + lowYear / 4 + highYear / 4 + 5 * highYear + 6) % 7;
-    return result;
-}
-
-int ISODateTime::maxWeekNumberInYear() const
-{
-    int day = dayOfWeek(m_year, 0, 1); // January 1.
-    return day == Thursday || (day == Wednesday && isLeapYear(m_year)) ? 53 : 52;
-}
-
-static unsigned countDigits(const UChar* src, unsigned length, unsigned start)
-{
-    unsigned index = start;
-    for (; index < length; ++index) {
-        if (!isASCIIDigit(src[index]))
-            break;
-    }
-    return index - start;
-}
-
-// Very strict integer parser. Do not allow leading or trailing whitespace unlike charactersToIntStrict().
-static bool toInt(const UChar* src, unsigned length, unsigned parseStart, unsigned parseLength, int& out)
-{
-    if (parseStart + parseLength > length || parseLength <= 0)
-        return false;
-    int value = 0;
-    const UChar* current = src + parseStart;
-    const UChar* end = current + parseLength;
-
-    // We don't need to handle negative numbers for ISO 8601.
-    for (; current < end; ++current) {
-        if (!isASCIIDigit(*current))
-            return false;
-        int digit = *current - '0';
-        if (value > (INT_MAX - digit) / 10) // Check for overflow.
-            return false;
-        value = value * 10 + digit;
-    }
-    out = value;
-    return true;
-}
-
-bool ISODateTime::parseYear(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    unsigned digitsLength = countDigits(src, length, start);
-    // Needs at least 4 digits according to the standard.
-    if (digitsLength < 4)
-        return false;
-    int year;
-    if (!toInt(src, length, start, digitsLength, year))
-        return false;
-    // No support for years before Gregorian calendar.
-    if (year < gregorianStartYear)
-        return false;
-    m_year = year;
-    end = start + digitsLength;
-    return true;
-}
-
-static bool beforeGregorianStartDate(int year, int month, int monthDay)
-{
-    return year < gregorianStartYear
-        || year == gregorianStartYear && month < gregorianStartMonth
-        || year == gregorianStartYear && month == gregorianStartMonth && monthDay < gregorianStartDay;
-}
-
-bool ISODateTime::addDay(int dayDiff)
-{
-    ASSERT(m_monthDay);
-
-    int day = m_monthDay + dayDiff;
-    if (day > maxDayOfMonth(m_year, m_month)) {
-        day = m_monthDay;
-        int year = m_year;
-        int month = m_month;
-        int maxDay = maxDayOfMonth(year, month);
-        for (; dayDiff > 0; --dayDiff) {
-            ++day;
-            if (day > maxDay) {
-                day = 1;
-                ++month;
-                if (month >= 12) { // month is 0-origin.
-                    month = 0;
-                    ++year;
-                    if (year < 0) // Check for overflow.
-                        return false;
-                }
-                maxDay = maxDayOfMonth(year, month);
-            }
-        }
-        m_year = year;
-        m_month = month;
-    } else if (day < 1) {
-        int month = m_month;
-        int year = m_year;
-        day = m_monthDay;
-        for (; dayDiff < 0; ++dayDiff) {
-            --day;
-            if (day < 1) {
-                --month;
-                if (month < 0) {
-                    month = 11;
-                    --year;
-                }
-                day = maxDayOfMonth(year, month);
-            }
-            if (beforeGregorianStartDate(year, month, day))
-                return false;
-        }
-        m_year = year;
-        m_month = month;
-    }
-    m_monthDay = day;
-    return true;
-}
-
-bool ISODateTime::addMinute(int minute)
-{
-    int carry;
-    // min can be negative or greater than 59.
-    minute += m_minute;
-    if (minute > 59) {
-        carry = minute / 60;
-        minute = minute % 60;
-    } else if (m_minute < 0) {
-        carry = (59 - m_minute) / 60;
-        minute += carry * 60;
-        carry = -carry;
-        ASSERT(minute >= 0 && minute <= 59);
-    } else {
-        m_minute = minute;
-        return true;
-    }
-
-    int hour = m_hour + carry;
-    if (hour > 23) {
-        carry = hour / 24;
-        hour = hour % 24;
-    } else if (hour < 0) {
-        carry = (23 - hour) / 24;
-        hour += carry * 24;
-        carry = -carry;
-        ASSERT(hour >= 0 && hour <= 23);
-    } else {
-        m_minute = minute;
-        m_hour = hour;
-        return true;
-    }
-    if (!addDay(carry))
-        return false;
-    m_minute = minute;
-    m_hour = hour;
-    return true;
-}
-
-// Parses a timezone part, and adjust year, month, monthDay, hour, minute, second, millisecond.
-bool ISODateTime::parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    if (start >= length)
-        return false;
-    unsigned index = start;
-    if (src[index] == 'Z') {
-        end = index + 1;
-        return true;
-    }
-
-    bool minus;
-    if (src[index] == '+')
-        minus = false;
-    else if (src[index] == '-')
-        minus = true;
-    else
-        return false;
-    ++index;
-
-    int hour;
-    int minute;
-    if (!toInt(src, length, index, 2, hour) || hour < 0 || hour > 23)
-        return false;
-    index += 2;
-
-    if (index >= length || src[index] != ':')
-        return false;
-    ++index;
-
-    if (!toInt(src, length, index, 2, minute) || minute < 0 || minute > 59)
-        return false;
-    index += 2;
-
-    if (minus) {
-        hour = -hour;
-        minute = -minute;
-    }
-
-    // Subtract the timezone offset.
-    if (!addMinute(-(hour * 60 + minute)))
-        return false;
-    end = index;
-    return true;
-}
-
-bool ISODateTime::parseMonth(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    unsigned index;
-    if (!parseYear(src, length, start, index))
-        return false;
-    if (index >= length || src[index] != '-')
-        return false;
-    ++index;
-
-    int month;
-    if (!toInt(src, length, index, 2, month) || month < 1 || month > 12)
-        return false;
-    --month;
-    // No support for months before Gregorian calendar.
-    if (beforeGregorianStartDate(m_year, month, gregorianStartDay))
-        return false;
-    m_month = month;
-    end = index + 2;
-    m_type = Month;
-    return true;
-}
-
-bool ISODateTime::parseDate(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    unsigned index;
-    if (!parseMonth(src, length, start, index))
-        return false;
-    // '-' and 2-digits are needed.
-    if (index + 2 >= length)
-        return false;
-    if (src[index] != '-')
-        return false;
-    ++index;
-
-    int day;
-    if (!toInt(src, length, index, 2, day) || day < 1 || day > maxDayOfMonth(m_year, m_month))
-        return false;
-    // No support for dates before Gregorian calendar.
-    if (m_year == gregorianStartYear && m_month == gregorianStartMonth && day < gregorianStartDay)
-        return false;
-    m_monthDay = day;
-    end = index + 2;
-    m_type = Date;
-    return true;
-}
-
-bool ISODateTime::parseWeek(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    unsigned index;
-    if (!parseYear(src, length, start, index))
-        return false;
-
-    // 4 characters ('-' 'W' digit digit) are needed.
-    if (index + 3 >= length)
-        return false;
-    if (src[index] != '-')
-        return false;
-    ++index;
-    if (src[index] != 'W')
-        return false;
-    ++index;
-
-    int week;
-    if (!toInt(src, length, index, 2, week) || week < 1 || week > maxWeekNumberInYear())
-        return false;
-    // No support for years older than or equals to Gregorian calendar start year.
-    if (m_year <= gregorianStartYear)
-        return false;
-    m_week = week;
-    end = index + 2;
-    m_type = Week;
-    return true;
-}
-
-bool ISODateTime::parseTime(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    int hour;
-    if (!toInt(src, length, start, 2, hour) || hour < 0 || hour > 23)
-        return false;
-    unsigned index = start + 2;
-    if (index >= length)
-        return false;
-    if (src[index] != ':')
-        return false;
-    ++index;
-
-    int minute;
-    if (!toInt(src, length, index, 2, minute) || minute < 0 || minute > 59)
-        return false;
-    index += 2;
-
-    int second = 0;
-    int millisecond = 0;
-    // Optional second part.
-    // Do not return with false because the part is optional.
-    if (index + 2 < length && src[index] == ':') {
-        if (toInt(src, length, index + 1, 2, second) && second >= 0 && second <= 59) {
-            index += 3;
-
-            // Optional fractional second part.
-            if (index < length && src[index] == '.') {
-                unsigned digitsLength = countDigits(src, length, index + 1);
-                if (digitsLength >  0) {
-                    ++index;
-                    bool ok;
-                    if (digitsLength == 1) {
-                        ok = toInt(src, length, index, 1, millisecond);
-                        millisecond *= 100;
-                    } else if (digitsLength == 2) {
-                        ok = toInt(src, length, index, 2, millisecond);
-                        millisecond *= 10;
-                    } else // digitsLength >= 3
-                        ok = toInt(src, length, index, 3, millisecond);
-                    ASSERT(ok);
-                    index += digitsLength;
-                }
-            }
-        }
-    }
-    m_hour = hour;
-    m_minute = minute;
-    m_second = second;
-    m_millisecond = millisecond;
-    end = index;
-    m_type = Time;
-    return true;
-}
-
-bool ISODateTime::parseDateTimeLocal(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    unsigned index;
-    if (!parseDate(src, length, start, index))
-        return false;
-    if (index >= length)
-        return false;
-    if (src[index] != 'T')
-        return false;
-    ++index;
-    if (!parseTime(src, length, index, end))
-        return false;
-    m_type = DateTimeLocal;
-    return true;
-}
-
-bool ISODateTime::parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end)
-{
-    ASSERT(src);
-    unsigned index;
-    if (!parseDate(src, length, start, index))
-        return false;
-    if (index >= length)
-        return false;
-    if (src[index] != 'T')
-        return false;
-    ++index;
-    if (!parseTime(src, length, index, index))
-        return false;
-    if (!parseTimeZone(src, length, index, end))
-        return false;
-    m_type = DateTime;
-    return true;
-}
-
-static inline double positiveFmod(double value, double divider)
-{
-    double remainder = fmod(value, divider);
-    return remainder < 0 ? remainder + divider : remainder;
-}
-
-void ISODateTime::setMillisecondsSinceMidnightInternal(double msInDay)
-{
-    ASSERT(msInDay >= 0 && msInDay < msPerDay);
-    m_millisecond = static_cast<int>(fmod(msInDay, msPerSecond));
-    double value = floor(msInDay / msPerSecond);
-    m_second = static_cast<int>(fmod(value, secondsPerMinute));
-    value = floor(value / secondsPerMinute);
-    m_minute = static_cast<int>(fmod(value, minutesPerHour));
-    m_hour = static_cast<int>(value / minutesPerHour);
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForDateInternal(double ms)
-{
-    m_year = msToYear(ms);
-    int yearDay = dayInYear(ms, m_year);
-    m_month = monthFromDayInYear(yearDay, isLeapYear(m_year));
-    m_monthDay = dayInMonthFromDayInYear(yearDay, isLeapYear(m_year));
-    return true;
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForDate(double ms)
-{
-    m_type = Invalid;
-    if (!isfinite(ms))
-        return false;
-    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
-        return false;
-    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
-        return false;
-    m_type = Date;
-    return true;
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForDateTime(double ms)
-{
-    m_type = Invalid;
-    if (!isfinite(ms))
-        return false;
-    ms = round(ms);
-    setMillisecondsSinceMidnightInternal(positiveFmod(ms, msPerDay));
-    if (!setMillisecondsSinceEpochForDateInternal(ms))
-        return false;
-    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
-        return false;
-    m_type = DateTime;
-    return true;
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForDateTimeLocal(double ms)
-{
-    // Internal representation of DateTimeLocal is the same as DateTime except m_type.
-    if (!setMillisecondsSinceEpochForDateTime(ms))
-        return false;
-    m_type = DateTimeLocal;
-    return true;
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms)
-{
-    m_type = Invalid;
-    if (!isfinite(ms))
-        return false;
-    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
-        return false;
-    // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal().
-    if (beforeGregorianStartDate(m_year, m_month, gregorianStartDay))
-        return false;
-    m_type = Month;
-    return true;
-}
-
-bool ISODateTime::setMillisecondsSinceMidnight(double ms)
-{
-    m_type = Invalid;
-    if (!isfinite(ms))
-        return false;
-    setMillisecondsSinceMidnightInternal(positiveFmod(round(ms), msPerDay));
-    m_type = Time;
-    return true;
-}
-
-// Offset from January 1st to Monday of the ISO 8601's first week.
-//   ex. If January 1st is Friday, such Monday is 3 days later. Returns 3.
-static int offsetTo1stWeekStart(int year)
-{
-    int offsetTo1stWeekStart = 1 - dayOfWeek(year, 0, 1);
-    if (offsetTo1stWeekStart <= -4)
-        offsetTo1stWeekStart += 7;
-    return offsetTo1stWeekStart;
-}
-
-bool ISODateTime::setMillisecondsSinceEpochForWeek(double ms)
-{
-    m_type = Invalid;
-    if (!isfinite(ms))
-        return false;
-    ms = round(ms);
-
-    m_year = msToYear(ms);
-    // We don't support gregorianStartYear. Week numbers are undefined in that year.
-    if (m_year <= gregorianStartYear)
-        return false;
-
-    int yearDay = dayInYear(ms, m_year);
-    int offset = offsetTo1stWeekStart(m_year);
-    if (yearDay < offset) {
-        // The day belongs to the last week of the previous year.
-        m_year--;
-        if (m_year <= gregorianStartYear)
-            return false;
-        m_week = maxWeekNumberInYear();
-    } else {
-        m_week = ((yearDay - offset) / 7) + 1;
-        if (m_week > maxWeekNumberInYear()) {
-            m_year++;
-            m_week = 1;
-        }
-    }
-    m_type = Week;
-    return true;
-}
-
-double ISODateTime::millisecondsSinceEpochForTime() const
-{
-    ASSERT(m_type == Time || m_type == DateTime || m_type == DateTimeLocal);
-    return ((m_hour * minutesPerHour + m_minute) * secondsPerMinute + m_second) * msPerSecond + m_millisecond;
-}
-
-double ISODateTime::millisecondsSinceEpoch() const
-{
-    switch (m_type) {
-    case Date:
-        return dateToDaysFrom1970(m_year, m_month, m_monthDay) * msPerDay;
-    case DateTime:
-    case DateTimeLocal:
-        return dateToDaysFrom1970(m_year, m_month, m_monthDay) * msPerDay + millisecondsSinceEpochForTime();
-    case Month:
-        return dateToDaysFrom1970(m_year, m_month, 1) * msPerDay;
-    case Time:
-        return millisecondsSinceEpochForTime();
-    case Week:
-        return (dateToDaysFrom1970(m_year, 0, 1) + offsetTo1stWeekStart(m_year) + (m_week - 1) * 7) * msPerDay;
-    case Invalid:
-        break;
-    }
-    ASSERT_NOT_REACHED();
-    return invalidMilliseconds();
-}
-
-String ISODateTime::toStringForTime(SecondFormat format) const
-{
-    ASSERT(m_type == DateTime || m_type == DateTimeLocal || m_type == Time);
-    SecondFormat effectiveFormat = format;
-    if (m_millisecond)
-        effectiveFormat = Millisecond;
-    else if (format == None && m_second)
-        effectiveFormat = Second;
-
-    switch (effectiveFormat) {
-    default:
-        ASSERT_NOT_REACHED();
-        // Fallback to None.
-    case None:
-        return String::format("%02d:%02d", m_hour, m_minute);
-    case Second:
-        return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second);
-    case Millisecond:
-        return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond);
-    }
-}
-
-String ISODateTime::toString(SecondFormat format) const
-{
-    switch (m_type) {
-    case Date:
-        return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
-    case DateTime:
-        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
-            + toStringForTime(format) + String("Z");
-    case DateTimeLocal:
-        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
-            + toStringForTime(format);
-    case Month:
-        return String::format("%04d-%02d", m_year, m_month + 1);
-    case Time:
-        return toStringForTime(format);
-    case Week:
-        return String::format("%04d-W%02d", m_year, m_week);
-    case Invalid:
-        break;
-    }
-    ASSERT_NOT_REACHED();
-    return String("(Invalid ISODateTime)");
-}
-
-} // namespace WebCore
diff --git a/WebCore/html/ISODateTime.h b/WebCore/html/ISODateTime.h
deleted file mode 100644
index ced503a..0000000
--- a/WebCore/html/ISODateTime.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ISODateTime_h
-#define ISODateTime_h
-
-#include <limits>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class String;
-
-// An ISODateTime instance represents one of the following date and time combinations:
-// * Month type: year-month
-// * Date type: year-month-day
-// * Week type: year-week
-// * Time type: hour-minute-second-millisecond
-// * DateTime or DateTimeLocal type: year-month-day hour-minute-second-millisecond
-class ISODateTime {
-public:
-    ISODateTime()
-        : m_millisecond(0)
-        , m_second(0)
-        , m_minute(0)
-        , m_hour(0)
-        , m_monthDay(0)
-        , m_month(0)
-        , m_year(0)
-        , m_week(0)
-        , m_type(Invalid)
-    {
-    }
-
-    int millisecond() const { return m_millisecond; }
-    int second() const { return m_second; }
-    int minute() const { return m_minute; }
-    int hour() const { return m_hour; }
-    int monthDay() const { return m_monthDay; }
-    int month() const { return m_month; }
-    int fullYear() const { return m_year; }
-    int week() const { return m_week; }
-
-    enum SecondFormat {
-        None, // Suppress the second part and the millisecond part if they are 0.
-        Second, // Always show the second part, and suppress the millisecond part if it is 0.
-        Millisecond // Always show the second part and the millisecond part.
-    };
-
-    // Returns an ISO 8601 representation for this instance.
-    // The format argument is valid for DateTime, DateTimeLocal, and Time types.
-    String toString(SecondFormat format = None) const;
-
-    // parse*() and setMillisecondsSince*() functions are initializers for an
-    // ISODateTime instance. If these functions return false, the instance
-    // might be invalid.
-
-    // The following six functions parse the input 'src' whose length is
-    // 'length', and updates some fields of this instance. The parsing starts at
-    // src[start] and examines characters before src[length].
-    // 'src' must be non-null. The 'src' string doesn't need to be
-    // null-terminated.
-    // The functions return true if the parsing succeeds, and set 'end' to the
-    // next index after the last consumed. Extra leading characters cause parse
-    // failures, and the trailing extra characters don't cause parse failures.
-
-    // Sets year and month.
-    bool parseMonth(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Sets year, month and monthDay.
-    bool parseDate(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Sets year and week.
-    bool parseWeek(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Sets hour, minute, second and millisecond.
-    bool parseTime(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Sets year, month, monthDay, hour, minute, second and millisecond.
-    bool parseDateTimeLocal(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Sets year, month, monthDay, hour, minute, second and millisecond, and adjusts timezone.
-    bool parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end);
-
-    // The following setMillisecondsSinceEpochFor*() functions take
-    // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as
-    // the argument, and update all fields for the corresponding
-    // ISODateTime type. The functions return true if it succeeds, and
-    // false if they fail.
-
-    // For Date type. Updates m_year, m_month and m_monthDay.
-    bool setMillisecondsSinceEpochForDate(double ms);
-    // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
-    bool setMillisecondsSinceEpochForDateTime(double ms);
-    // For DateTimeLocal type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
-    bool setMillisecondsSinceEpochForDateTimeLocal(double ms);
-    // For Month type. Updates m_year and m_month.
-    bool setMillisecondsSinceEpochForMonth(double ms);
-    // For Week type. Updates m_year and m_week.
-    bool setMillisecondsSinceEpochForWeek(double ms);
-
-    // For Time type. Updates m_hour, m_minute, m_second and m_millisecond.
-    bool setMillisecondsSinceMidnight(double ms);
-
-    // Returns the number of milliseconds from 1970-01-01 00:00:00 UTC.
-    // For an ISODateTime initialized with parseDateTimeLocal(),
-    // millisecondsSinceEpoch() returns a value for UTC timezone.
-    double millisecondsSinceEpoch() const;
-    static inline double invalidMilliseconds() { return std::numeric_limits<double>::quiet_NaN(); }
-
-private:
-    // Returns the maximum week number in this ISODateTime's year.
-    // The result is either of 52 and 53.
-    int maxWeekNumberInYear() const;
-    bool parseYear(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    bool addDay(int);
-    bool addMinute(int);
-    bool parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end);
-    // Helper for millisecondsSinceEpoch().
-    double millisecondsSinceEpochForTime() const;
-    // Helpers for setMillisecondsSinceEpochFor*().
-    bool setMillisecondsSinceEpochForDateInternal(double ms);
-    void setMillisecondsSinceMidnightInternal(double ms);
-    // Helper for toString().
-    String toStringForTime(SecondFormat) const;
-
-    // m_weekDay values
-    enum {
-        Sunday = 0,
-        Monday,
-        Tuesday,
-        Wednesday,
-        Thursday,
-        Friday,
-        Saturday,
-    };
-
-    int m_millisecond;  // 0 - 999
-    int m_second;
-    int m_minute;
-    int m_hour;
-    int m_monthDay;  // 1 - 31
-    int m_month;  // 0:January - 11:December
-    int m_year;  //  1582 -
-    int m_week;  // 1 - 53
-
-    enum Type {
-        Invalid,
-        Date,
-        DateTime,
-        DateTimeLocal,
-        Month,
-        Time,
-        Week,
-    };
-    Type m_type;
-};
-
-
-} // namespace WebCore
-
-#endif // ISODateTime_h
diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp
index e154cb3..1e0a07b 100644
--- a/WebCore/html/ValidityState.cpp
+++ b/WebCore/html/ValidityState.cpp
@@ -100,7 +100,7 @@ bool ValidityState::typeMismatch() const
     case HTMLInputElement::MONTH:
     case HTMLInputElement::TIME:
     case HTMLInputElement::WEEK:
-        return !HTMLInputElement::formStringToISODateTime(input->inputType(), value, 0);
+        return !HTMLInputElement::formStringToDateComponents(input->inputType(), value, 0);
     case HTMLInputElement::BUTTON:
     case HTMLInputElement::CHECKBOX:
     case HTMLInputElement::FILE:

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list