[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

tkent at chromium.org tkent at chromium.org
Thu Apr 8 01:14:00 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit c2baed753e6ece0f25705104678f2465033ea0fa
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 19 01:49:42 2010 +0000

    2010-01-18  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            HTMLInputElement::valueAsDate setter support for type=month.
            https://bugs.webkit.org/show_bug.cgi?id=33021
    
            Expose the following functions to be used by WebCore:
             - WTF::msToyear()
             - WTF::dayInYear()
             - WTF::monthFromDayInYear()
             - WTF::dayInMonthFromDayInYear()
    
            * JavaScriptCore.exp:
            * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
            * wtf/DateMath.cpp:
            (WTF::msToYear): Remove "static inline".
            (WTF::dayInYear): Remove "static inline".
            (WTF::monthFromDayInYear): Remove "static inline".
            (WTF::dayInMonthFromDayInYear): Remove "static inline".
            * wtf/DateMath.h: Declare the above functions.
    
    2010-01-18  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            HTMLInputElement::valueAsDate setter support for type=month.
            https://bugs.webkit.org/show_bug.cgi?id=33021
    
            Add setter tests to input-valueasdate-month.js, and update the
            expectation.
    
            * fast/forms/input-valueasdate-expected.txt:
            * fast/forms/input-valueasdate-month-expected.txt:
            * fast/forms/script-tests/input-valueasdate-month.js:
            * fast/forms/script-tests/input-valueasdate.js:
    
    2010-01-18  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            HTMLInputElement::valueAsDate setter support for type=month.
            https://bugs.webkit.org/show_bug.cgi?id=33021
    
            Introduce ISODateTime::setMillisecondsSinceEpochForMonth() and
            toString() for the Month type, and HTMLInputElement::setValueAsDate()
            calls them.
    
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::setValueAsDate):
            * html/ISODateTime.cpp:
            (WebCore::beforeGregorianStartDate):
            (WebCore::ISODateTime::addDay): Use beforeGregorianStartDate().
            (WebCore::ISODateTime::parseMonth): Use beforeGregorianStartDate().
            (WebCore::ISODateTime::setMillisecondsSinceEpochForDateInternal):
            (WebCore::ISODateTime::setMillisecondsSinceEpochForMonth):
            (WebCore::ISODateTime::toString): Implement only for the Month type.
            * html/ISODateTime.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53445 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 056d9e2..54f53bf 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-18  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        HTMLInputElement::valueAsDate setter support for type=month.
+        https://bugs.webkit.org/show_bug.cgi?id=33021
+
+        Expose the following functions to be used by WebCore:
+         - WTF::msToyear()
+         - WTF::dayInYear()
+         - WTF::monthFromDayInYear()
+         - WTF::dayInMonthFromDayInYear()
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        * wtf/DateMath.cpp:
+        (WTF::msToYear): Remove "static inline".
+        (WTF::dayInYear): Remove "static inline".
+        (WTF::monthFromDayInYear): Remove "static inline".
+        (WTF::dayInMonthFromDayInYear): Remove "static inline".
+        * wtf/DateMath.h: Declare the above functions.
+
 2010-01-18  Darin Adler  <darin at apple.com>
 
         Fix build by reverting the previous change.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index ff12845..4f8de91 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -319,6 +319,7 @@ __ZN3WTF15ThreadConditionD1Ev
 __ZN3WTF16callOnMainThreadEPFvPvES0_
 __ZN3WTF16fastZeroedMallocEm
 __ZN3WTF18dateToDaysFrom1970Eiii
+__ZN3WTF18monthFromDayInYearEib
 __ZN3WTF19initializeThreadingEv
 __ZN3WTF20fastMallocStatisticsEv
 __ZN3WTF21RefCountedLeakCounter16suppressMessagesEPKc
@@ -328,6 +329,7 @@ __ZN3WTF21RefCountedLeakCounter9incrementEv
 __ZN3WTF21RefCountedLeakCounterC1EPKc
 __ZN3WTF21RefCountedLeakCounterD1Ev
 __ZN3WTF23callOnMainThreadAndWaitEPFvPvES0_
+__ZN3WTF23dayInMonthFromDayInYearEib
 __ZN3WTF23waitForThreadCompletionEjPPv
 __ZN3WTF27releaseFastMallocFreeMemoryEv
 __ZN3WTF28setMainThreadCallbacksPausedEb
@@ -346,6 +348,8 @@ __ZN3WTF8Collator18setOrderLowerFirstEb
 __ZN3WTF8CollatorC1EPKc
 __ZN3WTF8CollatorD1Ev
 __ZN3WTF8fastFreeEPv
+__ZN3WTF8msToYearEd
+__ZN3WTF9dayInYearEdi
 __ZN3WTF9ByteArray6createEm
 __ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
 __ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index e2ba7c7..ebcc0f8 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -86,6 +86,8 @@ EXPORTS
     ?currentThread at WTF@@YAIXZ
     ?currentTime at WTF@@YANXZ
     ?dateToDaysFrom1970 at WTF@@YANHHH at Z
+    ?dayInMonthFromDayInYear at WTF@@YAHH_N at Z
+    ?dayInYear at WTF@@YAHNH at Z
     ?decrement at RefCountedLeakCounter@WTF@@QAEXXZ
     ?defaultAttributes at PropertyDescriptor@JSC@@0IA
     ?defaultValue at JSObject@JSC@@UBE?AVJSValue at 2@PAVExecState at 2@W4PreferredPrimitiveType at 2@@Z
@@ -194,6 +196,8 @@ EXPORTS
     ?markChildren at JSObject@JSC@@UAEXAAVMarkStack at 2@@Z
     ?markChildren at JSWrapperObject@JSC@@EAEXAAVMarkStack at 2@@Z
     ?materializePropertyMap at Structure@JSC@@AAEXXZ
+    ?monthFromDayInYear at WTF@@YAHH_N at Z
+    ?msToYear at WTF@@YAHN at Z
     ?name at InternalFunction@JSC@@QAEABVUString at 2@PAVExecState at 2@@Z
     ?nonInlineNaN at JSC@@YANXZ
     ?objectCount at Heap@JSC@@QBEIXZ
diff --git a/JavaScriptCore/wtf/DateMath.cpp b/JavaScriptCore/wtf/DateMath.cpp
index 202a557..6f4c862 100644
--- a/JavaScriptCore/wtf/DateMath.cpp
+++ b/JavaScriptCore/wtf/DateMath.cpp
@@ -172,7 +172,7 @@ static inline double msToDays(double ms)
     return floor(ms / msPerDay);
 }
 
-static inline int msToYear(double ms)
+int msToYear(double ms)
 {
     int approxYear = static_cast<int>(floor(ms / (msPerDay * 365.2425)) + 1970);
     double msFromApproxYearTo1970 = msPerDay * daysFrom1970ToYear(approxYear);
@@ -183,7 +183,7 @@ static inline int msToYear(double ms)
     return approxYear;
 }
 
-static inline int dayInYear(double ms, int year)
+int dayInYear(double ms, int year)
 {
     return static_cast<int>(msToDays(ms) - daysFrom1970ToYear(year));
 }
@@ -229,7 +229,7 @@ static inline int msToHours(double ms)
     return static_cast<int>(result);
 }
 
-static inline int monthFromDayInYear(int dayInYear, bool leapYear)
+int monthFromDayInYear(int dayInYear, bool leapYear)
 {
     const int d = dayInYear;
     int step;
@@ -267,7 +267,7 @@ static inline bool checkMonth(int dayInYear, int& startDayOfThisMonth, int& star
     return (dayInYear <= startDayOfNextMonth);
 }
 
-static inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear)
+int dayInMonthFromDayInYear(int dayInYear, bool leapYear)
 {
     const int d = dayInYear;
     int step;
diff --git a/JavaScriptCore/wtf/DateMath.h b/JavaScriptCore/wtf/DateMath.h
index 3a9de22..033d25e 100644
--- a/JavaScriptCore/wtf/DateMath.h
+++ b/JavaScriptCore/wtf/DateMath.h
@@ -78,13 +78,21 @@ const double msPerMonth = 2592000000.0;
 
 // Returns the number of days from 1970-01-01 to the specified date.
 double dateToDaysFrom1970(int year, int month, int day);
+int msToYear(double ms);
+int dayInYear(double ms, int year);
+int monthFromDayInYear(int dayInYear, bool leapYear);
+int dayInMonthFromDayInYear(int dayInYear, bool leapYear);
 
 } // namespace WTF
 
 using WTF::dateToDaysFrom1970;
+using WTF::dayInMonthFromDayInYear;
+using WTF::dayInYear;
 using WTF::minutesPerHour;
+using WTF::monthFromDayInYear;
 using WTF::msPerDay;
 using WTF::msPerSecond;
+using WTF::msToYear;
 using WTF::secondsPerMinute;
 
 #if USE(JSC)
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 482d7fb..0b1eefd 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-01-18  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        HTMLInputElement::valueAsDate setter support for type=month.
+        https://bugs.webkit.org/show_bug.cgi?id=33021
+
+        Add setter tests to input-valueasdate-month.js, and update the
+        expectation.
+
+        * fast/forms/input-valueasdate-expected.txt:
+        * fast/forms/input-valueasdate-month-expected.txt:
+        * fast/forms/script-tests/input-valueasdate-month.js:
+        * fast/forms/script-tests/input-valueasdate.js:
+
 2010-01-18  Enrica Casucci  <enrica at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/forms/input-valueasdate-expected.txt b/LayoutTests/fast/forms/input-valueasdate-expected.txt
index 33a4b18..726f343 100644
--- a/LayoutTests/fast/forms/input-valueasdate-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-expected.txt
@@ -18,9 +18,9 @@ Sets a number 0:
 PASS input.value is "1970-01"
 PASS input.valueAsDate.getTime() is 0
 Sets other types:
-PASS input.valueAsDate = null threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
-PASS input.valueAsDate = undefined threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
-PASS input.valueAsDate = document threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS input.value is ""
+PASS input.value is ""
+PASS input.value is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/input-valueasdate-month-expected.txt b/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
index 8dd71e7..ac5ef74 100644
--- a/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-month-expected.txt
@@ -7,6 +7,18 @@ PASS valueAsDateFor("") is null
 PASS valueAsDateFor("1969-12").getTime() is Date.UTC(1969, 11, 1, 0, 0, 0, 0)
 PASS valueAsDateFor("1970-01").getTime() is Date.UTC(1970, 0, 1)
 PASS valueAsDateFor("2009-12").getTime() is Date.UTC(2009, 11, 1)
+PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12"
+PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01"
+PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12"
+PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01"
+PASS setValueAsDateAndGetValue(794, 9, 22) is ""
+PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
+PASS setValueAsDateAndGetValue(1582, 9, 1) is "1582-10"
+PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10"
+PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09"
+PASS setValueAsDateAndGetValue(275760, 8, 14) is ""
+Sets null to valueAsDate:
+PASS input.value is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
index 63cb281..b34d69d 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-month.js
@@ -8,9 +8,33 @@ function valueAsDateFor(stringValue) {
     return input.valueAsDate;
 }
 
+function setValueAsDateAndGetValue(year, month, day) {
+    var date = new Date();
+    date.setTime(Date.UTC(year, month, day));
+    input.valueAsDate = date;
+    return input.value;
+}
+
 shouldBe('valueAsDateFor("")', 'null');
 shouldBe('valueAsDateFor("1969-12").getTime()', 'Date.UTC(1969, 11, 1, 0, 0, 0, 0)');
 shouldBe('valueAsDateFor("1970-01").getTime()', 'Date.UTC(1970, 0, 1)');
 shouldBe('valueAsDateFor("2009-12").getTime()', 'Date.UTC(2009, 11, 1)');
 
+shouldBe('setValueAsDateAndGetValue(1969, 11, 1)', '"1969-12"');
+shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01"');
+shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12"');
+shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01"');
+
+shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""');
+shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""');
+shouldBe('setValueAsDateAndGetValue(1582, 9, 1)', '"1582-10"');
+shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10"');
+shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09"');
+shouldBe('setValueAsDateAndGetValue(275760, 8, 14)', '""'); // Date of JavaScript can't represent this.
+
+debug('Sets null to valueAsDate:');
+input.value = '2009-12';
+input.valueAsDate = null;
+shouldBe('input.value', '""');
+
 var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate.js b/LayoutTests/fast/forms/script-tests/input-valueasdate.js
index 779679a..a1a7a6e 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate.js
@@ -28,8 +28,15 @@ input.valueAsDate = 0;
 shouldBe('input.value', '"1970-01"');
 shouldBe('input.valueAsDate.getTime()', '0');
 debug('Sets other types:');
-shouldThrow('input.valueAsDate = null', 'invalidStateError');
-shouldThrow('input.valueAsDate = undefined', 'invalidStateError');
-shouldThrow('input.valueAsDate = document', 'invalidStateError');
+input.value = '1970-01';
+input.valueAsDate = null;
+shouldBe('input.value', '""');
+input.value = '1970-01';
+input.valueAsDate = undefined;
+shouldBe('input.value', '""');
+input.value = '1970-01';
+input.valueAsDate = document;
+shouldBe('input.value', '""');
+
 
 var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3e4a3e1..d4d3a15 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-18  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        HTMLInputElement::valueAsDate setter support for type=month.
+        https://bugs.webkit.org/show_bug.cgi?id=33021
+
+        Introduce ISODateTime::setMillisecondsSinceEpochForMonth() and
+        toString() for the Month type, and HTMLInputElement::setValueAsDate()
+        calls them.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValueAsDate):
+        * html/ISODateTime.cpp:
+        (WebCore::beforeGregorianStartDate):
+        (WebCore::ISODateTime::addDay): Use beforeGregorianStartDate().
+        (WebCore::ISODateTime::parseMonth): Use beforeGregorianStartDate().
+        (WebCore::ISODateTime::setMillisecondsSinceEpochForDateInternal):
+        (WebCore::ISODateTime::setMillisecondsSinceEpochForMonth):
+        (WebCore::ISODateTime::toString): Implement only for the Month type.
+        * html/ISODateTime.h:
+
 2010-01-18  Enrica Casucci  <enrica at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index b2c88c5..57079b4 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1395,12 +1395,22 @@ double HTMLInputElement::valueAsDate() const
 
 void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
 {
-    // FIXME: This is a temporary implementation to check Date binding.
-    if (!isnan(value) && !isinf(value) && inputType() == MONTH) {
-        setValue(String("1970-01"));
+    ISODateTime dateTime;
+    bool success;
+    switch (inputType()) {
+    case MONTH:
+        success = dateTime.setMillisecondsSinceEpochForMonth(value);
+        break;
+    // FIXME: implementations for other supported types.
+    default:
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+    if (!success) {
+        setValue(String());
         return;
     }
-    ec = INVALID_STATE_ERR;
+    setValue(dateTime.toString());
 }
 
 String HTMLInputElement::placeholder() const
diff --git a/WebCore/html/ISODateTime.cpp b/WebCore/html/ISODateTime.cpp
index bef4808..adcc189 100644
--- a/WebCore/html/ISODateTime.cpp
+++ b/WebCore/html/ISODateTime.cpp
@@ -31,9 +31,11 @@
 #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 {
 
@@ -138,6 +140,13 @@ bool ISODateTime::parseYear(const UChar* src, unsigned length, unsigned start, u
     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);
@@ -178,9 +187,7 @@ bool ISODateTime::addDay(int dayDiff)
                 }
                 day = maxDayOfMonth(year, month);
             }
-            if (year < gregorianStartYear
-                    || (year == gregorianStartYear && month < gregorianStartMonth)
-                    || (year == gregorianStartYear && month == gregorianStartMonth && day < gregorianStartDay))
+            if (beforeGregorianStartDate(year, month, day))
                 return false;
         }
         m_year = year;
@@ -290,7 +297,7 @@ bool ISODateTime::parseMonth(const UChar* src, unsigned length, unsigned start,
         return false;
     --month;
     // No support for months before Gregorian calendar.
-    if (m_year == gregorianStartYear && month < gregorianStartMonth)
+    if (beforeGregorianStartDate(m_year, month, gregorianStartDay))
         return false;
     m_month = month;
     end = index + 2;
@@ -443,6 +450,28 @@ bool ISODateTime::parseDateTime(const UChar* src, unsigned length, unsigned star
     return true;
 }
 
+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::setMillisecondsSinceEpochForMonth(double ms)
+{
+    if (!isfinite(ms))
+        return false;
+    if (!setMillisecondsSinceEpochForDateInternal(ms))
+        return false;
+    // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal().
+    if (beforeGregorianStartDate(m_year, m_month, gregorianStartDay))
+        return false;
+    m_type = Month;
+    return true;
+}
+
 double ISODateTime::millisecondsSinceEpochForTime() const
 {
     ASSERT(m_type == Time || m_type == DateTime);
@@ -476,4 +505,18 @@ double ISODateTime::millisecondsSinceEpoch() const
     return invalidMilliseconds();
 }
 
+String ISODateTime::toString() const
+{
+    switch (m_type) {
+    case Month:
+        return String::format("%04d-%02d", m_year, m_month + 1);
+
+    // FIXME: implementations for other types.
+    default:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return String("(Invalid ISODateTime)");
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/ISODateTime.h b/WebCore/html/ISODateTime.h
index 3cd01cb..aee20a0 100644
--- a/WebCore/html/ISODateTime.h
+++ b/WebCore/html/ISODateTime.h
@@ -36,12 +36,14 @@
 
 namespace WebCore {
 
+class String;
+
 // An ISODateTime instance represents one of the following date and time combinations:
-// * year-month
-// * year-month-day
-// * year-week
-// * hour-minute-second-millisecond
-// * year-month-day hour-minute-second-millisecond
+// * 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()
@@ -66,12 +68,15 @@ public:
     int fullYear() const { return m_year; }
     int week() const { return m_week; }
 
-    // The following six functions parse the input `src' whose length is
-    // `length', and updates some fields of this instance. The parsing starts at
+    // Returns an ISO 8601 representation for this instance.
+    String toString() const;
+
+    // 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' `date' must be non-null. The `src' string doesn't need to be
+    // '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
+    // 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.
 
@@ -88,6 +93,16 @@ public:
     // 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*() function takes
+    // 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 function returns true if it succeeds, and
+    // false if it fails.
+
+    // For Month type.  Updates m_year and m_month.
+    bool setMillisecondsSinceEpochForMonth(double ms);
+    // FIXME: Add setMillisecondsSinceEpochFor*() for other types.
+
     // 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.
@@ -104,6 +119,8 @@ private:
     bool parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end);
     // Helper for millisecondsSinceEpoch().
     double millisecondsSinceEpochForTime() const;
+    // Helper for setMillisecondsSinceEpochFor*().
+    bool setMillisecondsSinceEpochForDateInternal(double ms);
 
     // m_weekDay values
     enum {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list