Move GregorianDateTime from JSC to WTF namespace
authorparoga@webkit.org <paroga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2012 05:19:55 +0000 (05:19 +0000)
committerparoga@webkit.org <paroga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2012 05:19:55 +0000 (05:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91948

Reviewed by Geoffrey Garen.

Moving GregorianDateTime into the WTF namespace allows us to us to
use it in WebCore too. The new class has the same behaviour as the
old struct. Only the unused timeZone member has been removed.

Source/JavaScriptCore:

* runtime/DateConstructor.cpp:
* runtime/DateConversion.cpp:
* runtime/DateConversion.h:
* runtime/DateInstance.h:
* runtime/DatePrototype.cpp:
* runtime/JSDateMath.cpp:
* runtime/JSDateMath.h:

Source/WebCore:

* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):
* bridge/qt/qt_runtime_qt4.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):

Source/WTF:

* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/GregorianDateTime.h: Added.
(GregorianDateTime):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123425 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/DateConstructor.cpp
Source/JavaScriptCore/runtime/DateConversion.cpp
Source/JavaScriptCore/runtime/DateConversion.h
Source/JavaScriptCore/runtime/DateInstance.h
Source/JavaScriptCore/runtime/DatePrototype.cpp
Source/JavaScriptCore/runtime/JSDateMath.cpp
Source/JavaScriptCore/runtime/JSDateMath.h
Source/WTF/ChangeLog
Source/WTF/GNUmakefile.list.am
Source/WTF/WTF.gypi
Source/WTF/WTF.pro
Source/WTF/WTF.vcproj/WTF.vcproj
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/GregorianDateTime.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebCore/bridge/qt/qt_runtime_qt4.cpp

index 1ca96a9..c3501e8 100644 (file)
@@ -1,3 +1,22 @@
+2012-07-23  Patrick Gansterer  <paroga@webkit.org>
+
+        Move GregorianDateTime from JSC to WTF namespace
+        https://bugs.webkit.org/show_bug.cgi?id=91948
+
+        Reviewed by Geoffrey Garen.
+
+        Moving GregorianDateTime into the WTF namespace allows us to us to
+        use it in WebCore too. The new class has the same behaviour as the
+        old struct. Only the unused timeZone member has been removed.
+
+        * runtime/DateConstructor.cpp:
+        * runtime/DateConversion.cpp:
+        * runtime/DateConversion.h:
+        * runtime/DateInstance.h:
+        * runtime/DatePrototype.cpp:
+        * runtime/JSDateMath.cpp:
+        * runtime/JSDateMath.h:
+
 2012-07-23  Filip Pizlo  <fpizlo@apple.com>
 
         Property storage should grow in reverse address direction, to support butterflies
index 08b8150..0325080 100644 (file)
@@ -136,13 +136,13 @@ JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const Arg
         else {
             GregorianDateTime t;
             int year = JSC::toInt32(doubleArguments[0]);
-            t.year = (year >= 0 && year <= 99) ? year : year - 1900;
-            t.month = JSC::toInt32(doubleArguments[1]);
-            t.monthDay = (numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
-            t.hour = JSC::toInt32(doubleArguments[3]);
-            t.minute = JSC::toInt32(doubleArguments[4]);
-            t.second = JSC::toInt32(doubleArguments[5]);
-            t.isDST = -1;
+            t.setYear((year >= 0 && year <= 99) ? year : year - 1900);
+            t.setMonth(JSC::toInt32(doubleArguments[1]));
+            t.setMonthDay((numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1);
+            t.setHour(JSC::toInt32(doubleArguments[3]));
+            t.setMinute(JSC::toInt32(doubleArguments[4]));
+            t.setSecond(JSC::toInt32(doubleArguments[5]));
+            t.setIsDST(-1);
             double ms = (numArgs >= 7) ? doubleArguments[6] : 0;
             value = gregorianDateTimeToMS(exec, t, ms, false);
         }
@@ -214,12 +214,12 @@ static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec)
 
     GregorianDateTime t;
     int year = JSC::toInt32(doubleArguments[0]);
-    t.year = (year >= 0 && year <= 99) ? year : year - 1900;
-    t.month = JSC::toInt32(doubleArguments[1]);
-    t.monthDay = (n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
-    t.hour = JSC::toInt32(doubleArguments[3]);
-    t.minute = JSC::toInt32(doubleArguments[4]);
-    t.second = JSC::toInt32(doubleArguments[5]);
+    t.setYear((year >= 0 && year <= 99) ? year : year - 1900);
+    t.setMonth(JSC::toInt32(doubleArguments[1]));
+    t.setMonthDay((n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1);
+    t.setHour(JSC::toInt32(doubleArguments[3]));
+    t.setMinute(JSC::toInt32(doubleArguments[4]));
+    t.setSecond(JSC::toInt32(doubleArguments[5]));
     double ms = (n >= 7) ? doubleArguments[6] : 0;
     return JSValue::encode(jsNumber(timeClip(gregorianDateTimeToMS(exec, t, ms, true))));
 }
index 700a526..e8714c1 100644 (file)
@@ -58,38 +58,38 @@ namespace JSC {
 void formatDate(const GregorianDateTime &t, DateConversionBuffer& buffer)
 {
     snprintf(buffer, DateConversionBufferSize, "%s %s %02d %04d",
-        weekdayName[(t.weekDay + 6) % 7],
-        monthName[t.month], t.monthDay, t.year + 1900);
+        weekdayName[(t.weekDay() + 6) % 7],
+        monthName[t.month()], t.monthDay(), t.year() + 1900);
 }
 
 void formatDateUTCVariant(const GregorianDateTime &t, DateConversionBuffer& buffer)
 {
     snprintf(buffer, DateConversionBufferSize, "%s, %02d %s %04d",
-        weekdayName[(t.weekDay + 6) % 7],
-        t.monthDay, monthName[t.month], t.year + 1900);
+        weekdayName[(t.weekDay() + 6) % 7],
+        t.monthDay(), monthName[t.month()], t.year() + 1900);
 }
 
 void formatTime(const GregorianDateTime &t, DateConversionBuffer& buffer)
 {
-    int offset = abs(gmtoffset(t));
+    int offset = abs(t.utcOffset());
     char timeZoneName[70];
     struct tm gtm = t;
     strftime(timeZoneName, sizeof(timeZoneName), "%Z", &gtm);
 
     if (timeZoneName[0]) {
         snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d (%s)",
-            t.hour, t.minute, t.second,
-            gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName);
+            t.hour(), t.minute(), t.second(),
+            t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName);
     } else {
         snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d",
-            t.hour, t.minute, t.second,
-            gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
+            t.hour(), t.minute(), t.second(),
+            t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
     }
 }
 
 void formatTimeUTC(const GregorianDateTime &t, DateConversionBuffer& buffer)
 {
-    snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour, t.minute, t.second);
+    snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour(), t.minute(), t.second());
 }
 
 } // namespace JSC
index 814d537..0b078cd 100644 (file)
 #ifndef DateConversion_h
 #define DateConversion_h
 
+#include <wtf/GregorianDateTime.h>
+
 namespace JSC {
 
 class ExecState;
-struct GregorianDateTime;
 
 static const unsigned DateConversionBufferSize = 100;
 typedef char DateConversionBuffer[DateConversionBufferSize];
index 7c976a5..9742e68 100644 (file)
 
 #include "JSWrapperObject.h"
 
-namespace WTF {
-    struct GregorianDateTime;
-}
-
 namespace JSC {
 
     class DateInstance : public JSWrapperObject {
index d3d0fe5..aa65acd 100644 (file)
@@ -222,13 +222,13 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
 #if OS(WINDOWS)
     SYSTEMTIME systemTime;
     memset(&systemTime, 0, sizeof(systemTime));
-    systemTime.wYear = gdt.year + 1900;
-    systemTime.wMonth = gdt.month + 1;
-    systemTime.wDay = gdt.monthDay;
-    systemTime.wDayOfWeek = gdt.weekDay;
-    systemTime.wHour = gdt.hour;
-    systemTime.wMinute = gdt.minute;
-    systemTime.wSecond = gdt.second;
+    systemTime.wYear = gdt.year() + 1900;
+    systemTime.wMonth = gdt.month() + 1;
+    systemTime.wDay = gdt.monthDay();
+    systemTime.wDayOfWeek = gdt.weekDay();
+    systemTime.wHour = gdt.hour();
+    systemTime.wMinute = gdt.minute();
+    systemTime.wSecond = gdt.second();
 
     Vector<UChar, 128> buffer;
     size_t length = 0;
@@ -265,7 +265,7 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
 
     // Offset year if needed
     struct tm localTM = gdt;
-    int year = gdt.year + 1900;
+    int year = gdt.year() + 1900;
     bool yearNeedsOffset = year < 1900 || year > 2038;
     if (yearNeedsOffset)
         localTM.tm_year = equivalentYearForDST(year) - 1900;
@@ -357,7 +357,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms
 
     // hours
     if (maxArgs >= 4 && idx < numArgs) {
-        t->hour = 0;
+        t->setHour(0);
         double hours = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(hours);
         milliseconds += hours * msPerHour;
@@ -365,7 +365,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms
 
     // minutes
     if (maxArgs >= 3 && idx < numArgs && ok) {
-        t->minute = 0;
+        t->setMinute(0);
         double minutes = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(minutes);
         milliseconds += minutes * msPerMinute;
@@ -373,7 +373,7 @@ static bool fillStructuresUsingTimeArgs(ExecState* exec, int maxArgs, double* ms
     
     // seconds
     if (maxArgs >= 2 && idx < numArgs && ok) {
-        t->second = 0;
+        t->setSecond(0);
         double seconds = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(seconds);
         milliseconds += seconds * msPerSecond;
@@ -412,19 +412,19 @@ static bool fillStructuresUsingDateArgs(ExecState *exec, int maxArgs, double *ms
     if (maxArgs >= 3 && idx < numArgs) {
         double years = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(years);
-        t->year = toInt32(years - 1900);
+        t->setYear(toInt32(years - 1900));
     }
     // months
     if (maxArgs >= 2 && idx < numArgs && ok) {
         double months = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(months);
-        t->month = toInt32(months);
+        t->setMonth(toInt32(months));
     }
     // days
     if (idx < numArgs && ok) {
         double days = exec->argument(idx++).toIntegerPreserveNaN(exec);
         ok = isfinite(days);
-        t->monthDay = 0;
+        t->setMonthDay(0);
         *ms += days * msPerDay;
     }
     
@@ -567,10 +567,10 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)
     int ms = static_cast<int>(fmod(thisDateObj->internalNumber(), msPerSecond));
     if (ms < 0)
         ms += msPerSecond;
-    if (gregorianDateTime->year > 8099 || gregorianDateTime->year < -1900)
-        snprintf(buffer, sizeof(buffer) - 1, "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, ms);
+    if (gregorianDateTime->year() > 8099 || gregorianDateTime->year() < -1900)
+        snprintf(buffer, sizeof(buffer) - 1, "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
     else
-        snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year, gregorianDateTime->month + 1, gregorianDateTime->monthDay, gregorianDateTime->hour, gregorianDateTime->minute, gregorianDateTime->second, ms);
+        snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
     buffer[sizeof(buffer) - 1] = 0;
     return JSValue::encode(jsNontrivialString(exec, buffer));
 }
@@ -657,7 +657,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(1900 + gregorianDateTime->year));
+    return JSValue::encode(jsNumber(1900 + gregorianDateTime->year()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)
@@ -671,7 +671,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(1900 + gregorianDateTime->year));
+    return JSValue::encode(jsNumber(1900 + gregorianDateTime->year()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec)
@@ -703,7 +703,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->month));
+    return JSValue::encode(jsNumber(gregorianDateTime->month()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec)
@@ -717,7 +717,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMonth(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->month));
+    return JSValue::encode(jsNumber(gregorianDateTime->month()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec)
@@ -731,7 +731,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDate(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->monthDay));
+    return JSValue::encode(jsNumber(gregorianDateTime->monthDay()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec)
@@ -745,7 +745,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDate(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->monthDay));
+    return JSValue::encode(jsNumber(gregorianDateTime->monthDay()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec)
@@ -759,7 +759,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetDay(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->weekDay));
+    return JSValue::encode(jsNumber(gregorianDateTime->weekDay()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec)
@@ -773,7 +773,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCDay(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->weekDay));
+    return JSValue::encode(jsNumber(gregorianDateTime->weekDay()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec)
@@ -787,7 +787,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetHours(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->hour));
+    return JSValue::encode(jsNumber(gregorianDateTime->hour()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec)
@@ -801,7 +801,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCHours(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->hour));
+    return JSValue::encode(jsNumber(gregorianDateTime->hour()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec)
@@ -815,7 +815,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMinutes(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->minute));
+    return JSValue::encode(jsNumber(gregorianDateTime->minute()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec)
@@ -829,7 +829,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMinutes(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->minute));
+    return JSValue::encode(jsNumber(gregorianDateTime->minute()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec)
@@ -843,7 +843,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetSeconds(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->second));
+    return JSValue::encode(jsNumber(gregorianDateTime->second()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec)
@@ -857,7 +857,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCSeconds(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(gregorianDateTime->second));
+    return JSValue::encode(jsNumber(gregorianDateTime->second()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec)
@@ -903,7 +903,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetTimezoneOffset(ExecState* exec)
     const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
     if (!gregorianDateTime)
         return JSValue::encode(jsNaN());
-    return JSValue::encode(jsNumber(-gregorianDateTime->utcOffset / minutesPerHour));
+    return JSValue::encode(jsNumber(-gregorianDateTime->utcOffset() / minutesPerHour));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncSetTime(ExecState* exec)
@@ -1087,36 +1087,36 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec)
     if (!thisValue.inherits(&DateInstance::s_info))
         return throwVMTypeError(exec);
 
-    DateInstance* thisDateObj = asDateInstance(thisValue);     
+    DateInstance* thisDateObj = asDateInstance(thisValue);
     if (!exec->argumentCount()) { 
         JSValue result = jsNaN();
         thisDateObj->setInternalValue(exec->globalData(), result);
         return JSValue::encode(result);
     }
-    
+
     double milli = thisDateObj->internalNumber();
     double ms = 0;
 
     GregorianDateTime gregorianDateTime;
     if (isnan(milli))
         // Based on ECMA 262 B.2.5 (setYear)
-        // the time must be reset to +0 if it is NaN. 
+        // the time must be reset to +0 if it is NaN.
         msToGregorianDateTime(exec, 0, true, gregorianDateTime);
-    else {   
+    else {
         double secs = floor(milli / msPerSecond);
         ms = milli - secs * msPerSecond;
         if (const GregorianDateTime* other = thisDateObj->gregorianDateTime(exec))
             gregorianDateTime.copyFrom(*other);
     }
-    
+
     double year = exec->argument(0).toIntegerPreserveNaN(exec);
     if (!isfinite(year)) {
         JSValue result = jsNaN();
         thisDateObj->setInternalValue(exec->globalData(), result);
         return JSValue::encode(result);
     }
-            
-    gregorianDateTime.year = toInt32((year > 99 || year < 0) ? year - 1900 : year);
+
+    gregorianDateTime.setYear(toInt32((year > 99 || year < 0) ? year - 1900 : year));
     JSValue result = jsNumber(gregorianDateTimeToMS(exec, gregorianDateTime, ms, false));
     thisDateObj->setInternalValue(exec->globalData(), result);
     return JSValue::encode(result);
@@ -1135,7 +1135,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetYear(ExecState* exec)
         return JSValue::encode(jsNaN());
 
     // NOTE: IE returns the full year even in getYear.
-    return JSValue::encode(jsNumber(gregorianDateTime->year));
+    return JSValue::encode(jsNumber(gregorianDateTime->year()));
 }
 
 EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
index 0dbeea4..a784093 100644 (file)
@@ -203,8 +203,8 @@ double getUTCOffset(ExecState* exec)
 
 double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
 {
-    double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay);
-    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
+    double day = dateToDaysFrom1970(t.year() + 1900, t.month(), t.monthDay());
+    double ms = timeToMS(t.hour(), t.minute(), t.second(), milliSeconds);
     double result = (day * WTF::msPerDay) + ms;
 
     if (!inputIsUTC) { // convert to UTC
@@ -228,17 +228,16 @@ void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, Gregori
     }
 
     const int year = msToYear(ms);
-    tm.second   =  msToSeconds(ms);
-    tm.minute   =  msToMinutes(ms);
-    tm.hour     =  msToHours(ms);
-    tm.weekDay  =  msToWeekDay(ms);
-    tm.yearDay  =  dayInYear(ms, year);
-    tm.monthDay =  dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year));
-    tm.month    =  monthFromDayInYear(tm.yearDay, isLeapYear(year));
-    tm.year     =  year - 1900;
-    tm.isDST    =  dstOff != 0.0;
-    tm.utcOffset = static_cast<long>((dstOff + utcOff) / WTF::msPerSecond);
-    tm.timeZone = nullptr;
+    tm.setSecond(msToSeconds(ms));
+    tm.setMinute(msToMinutes(ms));
+    tm.setHour(msToHours(ms));
+    tm.setWeekDay(msToWeekDay(ms));
+    tm.setYearDay(dayInYear(ms, year));
+    tm.setMonthDay(dayInMonthFromDayInYear(tm.yearDay(), isLeapYear(year)));
+    tm.setMonth(monthFromDayInYear(tm.yearDay(), isLeapYear(year)));
+    tm.setYear(year - 1900);
+    tm.setIsDST(dstOff != 0.0);
+    tm.setUtcOffset(static_cast<long>((dstOff + utcOff) / WTF::msPerSecond));
 }
 
 double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateString)
index d592fee..c7fb5a9 100644 (file)
 #define JSDateMath_h
 
 #include <wtf/DateMath.h>
+#include <wtf/GregorianDateTime.h>
 
 namespace JSC {
 
 class ExecState;
 class UString;
-struct GregorianDateTime;
 
 void msToGregorianDateTime(ExecState*, double, bool outputIsUTC, GregorianDateTime&);
 double gregorianDateTimeToMS(ExecState*, const GregorianDateTime&, double, bool inputIsUTC);
@@ -57,88 +57,6 @@ double getUTCOffset(ExecState*);
 double parseDateFromNullTerminatedCharacters(ExecState*, const char* dateString);
 double parseDate(ExecState*, const UString&);
 
-// Intentionally overridding the default tm of the system.
-// The members of tm differ on various operating systems.
-struct GregorianDateTime {
-    WTF_MAKE_NONCOPYABLE(GregorianDateTime);
-public:
-    GregorianDateTime()
-        : second(0)
-        , minute(0)
-        , hour(0)
-        , weekDay(0)
-        , monthDay(0)
-        , yearDay(0)
-        , month(0)
-        , year(0)
-        , isDST(0)
-        , utcOffset(0)
-    {
-    }
-
-    operator tm() const
-    {
-        tm ret;
-        memset(&ret, 0, sizeof(ret));
-
-        ret.tm_sec   =  second;
-        ret.tm_min   =  minute;
-        ret.tm_hour  =  hour;
-        ret.tm_wday  =  weekDay;
-        ret.tm_mday  =  monthDay;
-        ret.tm_yday  =  yearDay;
-        ret.tm_mon   =  month;
-        ret.tm_year  =  year;
-        ret.tm_isdst =  isDST;
-
-#if HAVE(TM_GMTOFF)
-        ret.tm_gmtoff = static_cast<long>(utcOffset);
-#endif
-#if HAVE(TM_ZONE)
-        ret.tm_zone = timeZone.get();
-#endif
-
-        return ret;
-    }
-
-    void copyFrom(const GregorianDateTime& rhs)
-    {
-        second = rhs.second;
-        minute = rhs.minute;
-        hour = rhs.hour;
-        weekDay = rhs.weekDay;
-        monthDay = rhs.monthDay;
-        yearDay = rhs.yearDay;
-        month = rhs.month;
-        year = rhs.year;
-        isDST = rhs.isDST;
-        utcOffset = rhs.utcOffset;
-        if (rhs.timeZone) {
-            int inZoneSize = strlen(rhs.timeZone.get()) + 1;
-            timeZone = adoptArrayPtr(new char[inZoneSize]);
-            strncpy(timeZone.get(), rhs.timeZone.get(), inZoneSize);
-        } else
-            timeZone = nullptr;
-    }
-
-    int second;
-    int minute;
-    int hour;
-    int weekDay;
-    int monthDay;
-    int yearDay;
-    int month;
-    int year;
-    int isDST;
-    int utcOffset;
-    OwnArrayPtr<char> timeZone;
-};
-
-static inline int gmtoffset(const GregorianDateTime& t)
-{
-    return t.utcOffset;
-}
-
 } // namespace JSC
 
 #endif // JSDateMath_h
index 83d09c2..7254389 100644 (file)
@@ -1,3 +1,23 @@
+2012-07-23  Patrick Gansterer  <paroga@webkit.org>
+
+        Move GregorianDateTime from JSC to WTF namespace
+        https://bugs.webkit.org/show_bug.cgi?id=91948
+
+        Reviewed by Geoffrey Garen.
+
+        Moving GregorianDateTime into the WTF namespace allows us to us to
+        use it in WebCore too. The new class has the same behaviour as the
+        old struct. Only the unused timeZone member has been removed.
+
+        * GNUmakefile.list.am:
+        * WTF.gypi:
+        * WTF.pro:
+        * WTF.vcproj/WTF.vcproj:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/GregorianDateTime.h: Added.
+        (GregorianDateTime):
+
 2012-07-23  Rob Buis  <rbuis@rim.com>
 
         [BlackBerry] Merge createThreadInternal implementations
index 5f0ddd6..bb68bc2 100644 (file)
@@ -52,6 +52,7 @@ wtf_sources += \
     Source/WTF/wtf/Forward.h \
     Source/WTF/wtf/Functional.h \
     Source/WTF/wtf/GetPtr.h \
+    Source/WTF/wtf/GregorianDateTime.h \
     Source/WTF/wtf/HashCountedSet.h \
     Source/WTF/wtf/HashFunctions.h \
     Source/WTF/wtf/HashIterators.h \
index eb28070..ebb41a4 100644 (file)
@@ -34,6 +34,7 @@
             'wtf/Forward.h',
             'wtf/Functional.h',
             'wtf/GetPtr.h',
+            'wtf/GregorianDateTime.h',
             'wtf/HashCountedSet.h',
             'wtf/HashFunctions.h',
             'wtf/HashIterators.h',
index 4bcb0ff..68d8471 100644 (file)
@@ -61,6 +61,7 @@ HEADERS += \
     Forward.h \
     Functional.h \
     GetPtr.h \
+    GregorianDateTime.h \
     HashCountedSet.h \
     HashFunctions.h \
     HashIterators.h \
index d1a295c..1ac32b4 100644 (file)
                        >
                </File>
                <File
+                       RelativePath="..\wtf\GregorianDateTime.h"
+                       >
+               </File>
+               <File
                        RelativePath="..\wtf\HashCountedSet.h"
                        >
                </File>
index c47ec19..372c15e 100644 (file)
@@ -7,9 +7,10 @@
        objects = {
 
 /* Begin PBXBuildFile section */
+               0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
                143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; };
                143F61201565F0F900DB514A /* RAMSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 143F611E1565F0F900DB514A /* RAMSize.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
+               2C05385415BC819000F21B96 /* GregorianDateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C05385315BC819000F21B96 /* GregorianDateTime.h */; };
                4330F38F15745B0500AAFA8F /* URLString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4330F38E15745B0500AAFA8F /* URLString.cpp */; };
                4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0321BB156AA8D1006EBAF6 /* BitArray.h */; };
                8134013815B092FD001FF0B8 /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8134013615B092FD001FF0B8 /* Base64.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+               0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = "<group>"; };
                143F611D1565F0F900DB514A /* RAMSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RAMSize.cpp; sourceTree = "<group>"; };
                143F611E1565F0F900DB514A /* RAMSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAMSize.h; sourceTree = "<group>"; };
-               0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = "<group>"; };
+               2C05385315BC819000F21B96 /* GregorianDateTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GregorianDateTime.h; sourceTree = "<group>"; };
                4330F38E15745B0500AAFA8F /* URLString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLString.cpp; sourceTree = "<group>"; };
                4F0321BB156AA8D1006EBAF6 /* BitArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitArray.h; sourceTree = "<group>"; };
                5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
                5D247B7614689D7600E78B76 /* Source */ = {
                        isa = PBXGroup;
                        children = (
+                               A876DBD6151816E500DADB95 /* wtf */,
                                A8A4748B151A8264004123FF /* config.h */,
                                5D247EB11468B01500E78B76 /* HeaderDetection.h */,
-                               A876DBD6151816E500DADB95 /* wtf */,
                        );
                        name = Source;
                        sourceTree = "<group>";
                A876DBD6151816E500DADB95 /* wtf */ = {
                        isa = PBXGroup;
                        children = (
-                               143F611D1565F0F900DB514A /* RAMSize.cpp */,
-                               143F611E1565F0F900DB514A /* RAMSize.h */,
+                               A8A47281151A825A004123FF /* dtoa */,
+                               A8A472C4151A825A004123FF /* mac */,
+                               A8A4731B151A825B004123FF /* text */,
+                               A8A47339151A825B004123FF /* threads */,
+                               A8A47348151A825B004123FF /* unicode */,
+                               A8A4735E151A825B004123FF /* url */,
                                A8A47254151A825A004123FF /* Alignment.h */,
                                A8A47255151A825A004123FF /* AlwaysInline.h */,
                                A8A47256151A825A004123FF /* ArrayBuffer.cpp */,
                                A8A4725C151A825A004123FF /* Assertions.h */,
                                A8A4725D151A825A004123FF /* Atomics.h */,
                                A8A4725E151A825A004123FF /* AVLTree.h */,
-                               A8A4725F151A825A004123FF /* Bitmap.h */,
                                4F0321BB156AA8D1006EBAF6 /* BitArray.h */,
+                               A8A4725F151A825A004123FF /* Bitmap.h */,
                                A8A47260151A825A004123FF /* BitVector.cpp */,
                                A8A47261151A825A004123FF /* BitVector.h */,
                                A8A47264151A825A004123FF /* BlockStack.h */,
                                A8A4727E151A825A004123FF /* Deque.h */,
                                A8A4727F151A825A004123FF /* DisallowCType.h */,
                                A8A47280151A825A004123FF /* DoublyLinkedList.h */,
-                               A8A47281151A825A004123FF /* dtoa */,
                                A8A47297151A825A004123FF /* dtoa.cpp */,
                                A8A47298151A825A004123FF /* dtoa.h */,
                                A8A47299151A825A004123FF /* DynamicAnnotations.cpp */,
                                A8A472A6151A825A004123FF /* Forward.h */,
                                A8A472A7151A825A004123FF /* Functional.h */,
                                A8A472A8151A825A004123FF /* GetPtr.h */,
+                               2C05385315BC819000F21B96 /* GregorianDateTime.h */,
                                A8A472B3151A825A004123FF /* HashCountedSet.h */,
                                A8A472B4151A825A004123FF /* HashFunctions.h */,
                                A8A472B5151A825A004123FF /* HashIterators.h */,
                                A8A472BA151A825A004123FF /* HashTraits.h */,
                                A8A472BB151A825A004123FF /* HexNumber.h */,
                                A8A472BC151A825A004123FF /* InlineASM.h */,
-                               A8A472BD151A825A004123FF /* Int8Array.h */,
                                A8A472BE151A825A004123FF /* Int16Array.h */,
                                A8A472BF151A825A004123FF /* Int32Array.h */,
+                               A8A472BD151A825A004123FF /* Int8Array.h */,
                                A8A472C0151A825A004123FF /* IntegralTypedArrayBase.h */,
                                A8A472C1151A825A004123FF /* ListHashSet.h */,
                                A8A472C2151A825A004123FF /* ListRefPtr.h */,
                                A8A472C3151A825A004123FF /* Locker.h */,
-                               A8A472C4151A825A004123FF /* mac */,
                                A8A472C6151A825A004123FF /* MainThread.cpp */,
                                A8A472C7151A825B004123FF /* MainThread.h */,
                                A8A472C8151A825B004123FF /* MallocZoneSupport.h */,
                                A8A472ED151A825B004123FF /* PassRefPtr.h */,
                                A8A472EE151A825B004123FF /* PassTraits.h */,
                                A8A472EF151A825B004123FF /* Platform.h */,
+                               A876DBD7151816E500DADB95 /* Platform.h */,
                                A8A472F3151A825B004123FF /* PossiblyNull.h */,
+                               143F611D1565F0F900DB514A /* RAMSize.cpp */,
+                               143F611E1565F0F900DB514A /* RAMSize.h */,
                                A8A472FB151A825B004123FF /* RandomNumber.cpp */,
                                A8A472FC151A825B004123FF /* RandomNumber.h */,
                                A8A472FD151A825B004123FF /* RandomNumberSeed.h */,
                                A8A47318151A825B004123FF /* TCSystemAlloc.cpp */,
                                A8A47319151A825B004123FF /* TCSystemAlloc.h */,
                                A8A4731A151A825B004123FF /* TemporaryChange.h */,
-                               A8A4731B151A825B004123FF /* text */,
                                A8A4732F151A825B004123FF /* ThreadFunctionInvocation.h */,
                                A8A47330151A825B004123FF /* ThreadIdentifierDataPthreads.cpp */,
                                A8A47331151A825B004123FF /* ThreadIdentifierDataPthreads.h */,
                                A8A47335151A825B004123FF /* ThreadingPrimitives.h */,
                                A8A47336151A825B004123FF /* ThreadingPthreads.cpp */,
                                A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */,
-                               A8A47339151A825B004123FF /* threads */,
                                A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */,
                                A8A4733F151A825B004123FF /* ThreadSpecific.h */,
                                A8A47341151A825B004123FF /* TypedArrayBase.h */,
                                A8A47342151A825B004123FF /* TypeTraits.cpp */,
                                A8A47343151A825B004123FF /* TypeTraits.h */,
-                               A8A47344151A825B004123FF /* Uint8Array.h */,
-                               A8A47345151A825B004123FF /* Uint8ClampedArray.h */,
                                A8A47346151A825B004123FF /* Uint16Array.h */,
                                A8A47347151A825B004123FF /* Uint32Array.h */,
-                               A8A47348151A825B004123FF /* unicode */,
+                               A8A47344151A825B004123FF /* Uint8Array.h */,
+                               A8A47345151A825B004123FF /* Uint8ClampedArray.h */,
                                A8A4735C151A825B004123FF /* UnionFind.h */,
                                A8A4735D151A825B004123FF /* UnusedParam.h */,
-                               A8A4735E151A825B004123FF /* url */,
                                A8A4736F151A825B004123FF /* ValueCheck.h */,
                                A8A47370151A825B004123FF /* Vector.h */,
                                A8A47371151A825B004123FF /* VectorTraits.h */,
                                A8A47372151A825B004123FF /* VMTags.h */,
                                A8A4737A151A825B004123FF /* WTFThreadData.cpp */,
                                A8A4737B151A825B004123FF /* WTFThreadData.h */,
-                               A876DBD7151816E500DADB95 /* Platform.h */,
                        );
                        path = wtf;
                        sourceTree = "<group>";
                A8A47281151A825A004123FF /* dtoa */ = {
                        isa = PBXGroup;
                        children = (
+                               A8A47288151A825A004123FF /* COPYING */,
+                               A8A47292151A825A004123FF /* LICENSE */,
+                               A8A47293151A825A004123FF /* README */,
                                A8A47282151A825A004123FF /* bignum-dtoa.cc */,
                                A8A47283151A825A004123FF /* bignum-dtoa.h */,
                                A8A47284151A825A004123FF /* bignum.cc */,
                                A8A47285151A825A004123FF /* bignum.h */,
                                A8A47286151A825A004123FF /* cached-powers.cc */,
                                A8A47287151A825A004123FF /* cached-powers.h */,
-                               A8A47288151A825A004123FF /* COPYING */,
                                A8A47289151A825A004123FF /* diy-fp.cc */,
                                A8A4728A151A825A004123FF /* diy-fp.h */,
                                A8A4728B151A825A004123FF /* double-conversion.cc */,
                                A8A4728F151A825A004123FF /* fast-dtoa.h */,
                                A8A47290151A825A004123FF /* fixed-dtoa.cc */,
                                A8A47291151A825A004123FF /* fixed-dtoa.h */,
-                               A8A47292151A825A004123FF /* LICENSE */,
-                               A8A47293151A825A004123FF /* README */,
                                A8A47294151A825A004123FF /* strtod.cc */,
                                A8A47295151A825A004123FF /* strtod.h */,
                                A8A47296151A825A004123FF /* utils.h */,
                A8A4731B151A825B004123FF /* text */ = {
                        isa = PBXGroup;
                        children = (
-                               8134013615B092FD001FF0B8 /* Base64.cpp */,
-                               8134013715B092FD001FF0B8 /* Base64.h */,
                                A8A4731C151A825B004123FF /* ASCIIFastPath.h */,
                                A8A4731D151A825B004123FF /* AtomicString.cpp */,
                                A8A4731E151A825B004123FF /* AtomicString.h */,
                                A8A4731F151A825B004123FF /* AtomicStringHash.h */,
                                A8A47320151A825B004123FF /* AtomicStringImpl.h */,
+                               8134013615B092FD001FF0B8 /* Base64.cpp */,
+                               8134013715B092FD001FF0B8 /* Base64.h */,
                                A8A47321151A825B004123FF /* CString.cpp */,
                                A8A47322151A825B004123FF /* CString.h */,
                                A8A47323151A825B004123FF /* StringBuffer.h */,
                A8A47348151A825B004123FF /* unicode */ = {
                        isa = PBXGroup;
                        children = (
+                               A8A4734F151A825B004123FF /* icu */,
                                A8A47349151A825B004123FF /* CharacterNames.h */,
                                A8A4734A151A825B004123FF /* Collator.h */,
                                A8A4734B151A825B004123FF /* CollatorDefault.cpp */,
-                               A8A4734F151A825B004123FF /* icu */,
                                A8A47354151A825B004123FF /* ScriptCodesFromICU.h */,
                                A8A47355151A825B004123FF /* Unicode.h */,
                                A8A47356151A825B004123FF /* UnicodeMacrosFromICU.h */,
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               A876DBD8151816E500DADB95 /* Platform.h in Headers */,
                                A8A4737F151A825B004123FF /* Alignment.h in Headers */,
                                A8A47380151A825B004123FF /* AlwaysInline.h in Headers */,
                                A8A47382151A825B004123FF /* ArrayBuffer.h in Headers */,
                                A8A47384151A825B004123FF /* ArrayBufferView.h in Headers */,
                                A8A47385151A825B004123FF /* ASCIICType.h in Headers */,
+                               A8A47434151A825B004123FF /* ASCIIFastPath.h in Headers */,
                                A8A47387151A825B004123FF /* Assertions.h in Headers */,
                                A8A47388151A825B004123FF /* Atomics.h in Headers */,
+                               A8A47436151A825B004123FF /* AtomicString.h in Headers */,
+                               A8A47437151A825B004123FF /* AtomicStringHash.h in Headers */,
+                               A8A47438151A825B004123FF /* AtomicStringImpl.h in Headers */,
                                A8A47389151A825B004123FF /* AVLTree.h in Headers */,
-                               A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
+                               8134013915B092FD001FF0B8 /* Base64.h in Headers */,
+                               A8A473A9151A825B004123FF /* bignum-dtoa.h in Headers */,
+                               A8A473AB151A825B004123FF /* bignum.h in Headers */,
+                               A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */,
                                4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */,
+                               A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
                                A8A4738C151A825B004123FF /* BitVector.h in Headers */,
                                A8A4738E151A825B004123FF /* BlockStack.h in Headers */,
                                A8A4738F151A825B004123FF /* BloomFilter.h in Headers */,
                                A8A47390151A825B004123FF /* BoundsCheckedPointer.h in Headers */,
                                A8A47391151A825B004123FF /* BumpPointerAllocator.h in Headers */,
+                               A8A473AD151A825B004123FF /* cached-powers.h in Headers */,
+                               A8A4745E151A825B004123FF /* CharacterNames.h in Headers */,
                                A8A47394151A825B004123FF /* CheckedArithmetic.h in Headers */,
                                A8A47395151A825B004123FF /* CheckedBoolean.h in Headers */,
+                               A8A4745F151A825B004123FF /* Collator.h in Headers */,
                                A8A47398151A825B004123FF /* Compiler.h in Headers */,
                                A8A47399151A825B004123FF /* Complex.h in Headers */,
+                               A8A4748C151A8264004123FF /* config.h in Headers */,
                                A8A4739B151A825B004123FF /* CryptographicallyRandomNumber.h in Headers */,
+                               A8A4743A151A825B004123FF /* CString.h in Headers */,
                                A8A4739D151A825B004123FF /* CurrentTime.h in Headers */,
                                A8A4739F151A825B004123FF /* DataLog.h in Headers */,
                                A8A473A1151A825B004123FF /* DateMath.h in Headers */,
                                A8A473A4151A825B004123FF /* Decoder.h in Headers */,
                                A8A473A5151A825B004123FF /* Deque.h in Headers */,
                                A8A473A6151A825B004123FF /* DisallowCType.h in Headers */,
-                               A8A473A7151A825B004123FF /* DoublyLinkedList.h in Headers */,
-                               A8A473A9151A825B004123FF /* bignum-dtoa.h in Headers */,
-                               A8A473AB151A825B004123FF /* bignum.h in Headers */,
-                               A8A473AD151A825B004123FF /* cached-powers.h in Headers */,
                                A8A473AF151A825B004123FF /* diy-fp.h in Headers */,
                                A8A473B1151A825B004123FF /* double-conversion.h in Headers */,
                                A8A473B2151A825B004123FF /* double.h in Headers */,
-                               A8A473B4151A825B004123FF /* fast-dtoa.h in Headers */,
-                               A8A473B6151A825B004123FF /* fixed-dtoa.h in Headers */,
-                               A8A473B8151A825B004123FF /* strtod.h in Headers */,
-                               A8A473B9151A825B004123FF /* utils.h in Headers */,
+                               A8A473A7151A825B004123FF /* DoublyLinkedList.h in Headers */,
                                A8A473BB151A825B004123FF /* dtoa.h in Headers */,
                                A8A473BD151A825B004123FF /* DynamicAnnotations.h in Headers */,
                                A8A473C0151A825B004123FF /* Encoder.h in Headers */,
                                A8A473C1151A825B004123FF /* ExportMacros.h in Headers */,
+                               A8A473B4151A825B004123FF /* fast-dtoa.h in Headers */,
                                A8A473C2151A825B004123FF /* FastAllocBase.h in Headers */,
+                               0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */,
                                A8A473C4151A825B004123FF /* FastMalloc.h in Headers */,
+                               A8A473B6151A825B004123FF /* fixed-dtoa.h in Headers */,
                                A8A473C5151A825B004123FF /* FixedArray.h in Headers */,
                                A8A473C6151A825B004123FF /* Float32Array.h in Headers */,
                                A8A473C7151A825B004123FF /* Float64Array.h in Headers */,
                                A8A473C8151A825B004123FF /* Forward.h in Headers */,
                                A8A473C9151A825B004123FF /* Functional.h in Headers */,
                                A8A473CA151A825B004123FF /* GetPtr.h in Headers */,
+                               2C05385415BC819000F21B96 /* GregorianDateTime.h in Headers */,
                                A8A473D3151A825B004123FF /* HashCountedSet.h in Headers */,
                                A8A473D4151A825B004123FF /* HashFunctions.h in Headers */,
                                A8A473D5151A825B004123FF /* HashIterators.h in Headers */,
                                A8A473DA151A825B004123FF /* HashTraits.h in Headers */,
                                A8A473DB151A825B004123FF /* HexNumber.h in Headers */,
                                A8A473DC151A825B004123FF /* InlineASM.h in Headers */,
-                               A8A473DD151A825B004123FF /* Int8Array.h in Headers */,
                                A8A473DE151A825B004123FF /* Int16Array.h in Headers */,
                                A8A473DF151A825B004123FF /* Int32Array.h in Headers */,
+                               A8A473DD151A825B004123FF /* Int8Array.h in Headers */,
                                A8A473E0151A825B004123FF /* IntegralTypedArrayBase.h in Headers */,
                                A8A473E1151A825B004123FF /* ListHashSet.h in Headers */,
                                A8A473E2151A825B004123FF /* ListRefPtr.h in Headers */,
                                A8A47404151A825B004123FF /* PageReservation.h in Headers */,
                                A8A47405151A825B004123FF /* ParallelJobs.h in Headers */,
                                A8A47408151A825B004123FF /* ParallelJobsLibdispatch.h in Headers */,
+                               A8A47470151A825B004123FF /* ParsedURL.h in Headers */,
                                A8A4740A151A825B004123FF /* PassOwnArrayPtr.h in Headers */,
                                A8A4740B151A825B004123FF /* PassOwnPtr.h in Headers */,
                                A8A4740C151A825B004123FF /* PassRefPtr.h in Headers */,
                                A8A4740D151A825B004123FF /* PassTraits.h in Headers */,
+                               A876DBD8151816E500DADB95 /* Platform.h in Headers */,
                                A8A4740E151A825B004123FF /* Platform.h in Headers */,
                                A8A4740F151A825B004123FF /* PossiblyNull.h in Headers */,
+                               143F61201565F0F900DB514A /* RAMSize.h in Headers */,
                                A8A47415151A825B004123FF /* RandomNumber.h in Headers */,
                                A8A47416151A825B004123FF /* RandomNumberSeed.h in Headers */,
+                               A8A47472151A825B004123FF /* RawURLBuffer.h in Headers */,
                                A8A47417151A825B004123FF /* RedBlackTree.h in Headers */,
                                A8A47418151A825B004123FF /* RefCounted.h in Headers */,
                                A8A47419151A825B004123FF /* RefCountedArray.h in Headers */,
                                A8A4741C151A825B004123FF /* RefPtr.h in Headers */,
                                A8A4741D151A825B004123FF /* RefPtrHashMap.h in Headers */,
                                A8A4741E151A825B004123FF /* RetainPtr.h in Headers */,
+                               A8A47466151A825B004123FF /* ScriptCodesFromICU.h in Headers */,
                                A8A4741F151A825B004123FF /* SegmentedVector.h in Headers */,
                                A8A47420151A825B004123FF /* SentinelLinkedList.h in Headers */,
                                A8A47422151A825B004123FF /* SHA1.h in Headers */,
                                A8A47428151A825B004123FF /* StackBounds.h in Headers */,
                                A8A47429151A825B004123FF /* StaticConstructors.h in Headers */,
                                A8A4742A151A825B004123FF /* StdLibExtras.h in Headers */,
+                               A8A4743B151A825B004123FF /* StringBuffer.h in Headers */,
+                               A8A4743D151A825B004123FF /* StringBuilder.h in Headers */,
+                               A8A4743E151A825B004123FF /* StringConcatenate.h in Headers */,
                                A8A4742C151A825B004123FF /* StringExtras.h in Headers */,
+                               A8A4743F151A825B004123FF /* StringHash.h in Headers */,
                                A8A4742D151A825B004123FF /* StringHasher.h in Headers */,
+                               A8A47441151A825B004123FF /* StringImpl.h in Headers */,
+                               A8A47442151A825B004123FF /* StringOperators.h in Headers */,
+                               A8A473B8151A825B004123FF /* strtod.h in Headers */,
                                A8A4742E151A825B004123FF /* TCPackedCache.h in Headers */,
                                A8A4742F151A825B004123FF /* TCPageMap.h in Headers */,
                                A8A47430151A825B004123FF /* TCSpinLock.h in Headers */,
                                A8A47432151A825B004123FF /* TCSystemAlloc.h in Headers */,
                                A8A47433151A825B004123FF /* TemporaryChange.h in Headers */,
-                               A8A47434151A825B004123FF /* ASCIIFastPath.h in Headers */,
-                               A8A47436151A825B004123FF /* AtomicString.h in Headers */,
-                               A8A47437151A825B004123FF /* AtomicStringHash.h in Headers */,
-                               A8A47438151A825B004123FF /* AtomicStringImpl.h in Headers */,
-                               A8A4743A151A825B004123FF /* CString.h in Headers */,
-                               A8A4743B151A825B004123FF /* StringBuffer.h in Headers */,
-                               A8A4743D151A825B004123FF /* StringBuilder.h in Headers */,
-                               A8A4743E151A825B004123FF /* StringConcatenate.h in Headers */,
-                               A8A4743F151A825B004123FF /* StringHash.h in Headers */,
-                               A8A47441151A825B004123FF /* StringImpl.h in Headers */,
-                               A8A47442151A825B004123FF /* StringOperators.h in Headers */,
                                A8A47444151A825B004123FF /* TextPosition.h in Headers */,
-                               A8A47446151A825B004123FF /* WTFString.h in Headers */,
                                A8A47447151A825B004123FF /* ThreadFunctionInvocation.h in Headers */,
                                A8A47449151A825B004123FF /* ThreadIdentifierDataPthreads.h in Headers */,
                                A8A4744B151A825B004123FF /* Threading.h in Headers */,
                                A8A4744D151A825B004123FF /* ThreadingPrimitives.h in Headers */,
                                A8A47450151A825B004123FF /* ThreadRestrictionVerifier.h in Headers */,
-                               A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */,
                                A8A47454151A825B004123FF /* ThreadSafeRefCounted.h in Headers */,
                                A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */,
                                A8A47457151A825B004123FF /* TypedArrayBase.h in Headers */,
                                A8A47459151A825B004123FF /* TypeTraits.h in Headers */,
-                               A8A4745A151A825B004123FF /* Uint8Array.h in Headers */,
-                               A8A4745B151A825B004123FF /* Uint8ClampedArray.h in Headers */,
                                A8A4745C151A825B004123FF /* Uint16Array.h in Headers */,
                                A8A4745D151A825B004123FF /* Uint32Array.h in Headers */,
-                               A8A4745E151A825B004123FF /* CharacterNames.h in Headers */,
-                               A8A4745F151A825B004123FF /* Collator.h in Headers */,
-                               A8A47464151A825B004123FF /* UnicodeIcu.h in Headers */,
-                               A8A47466151A825B004123FF /* ScriptCodesFromICU.h in Headers */,
+                               A8A4745A151A825B004123FF /* Uint8Array.h in Headers */,
+                               A8A4745B151A825B004123FF /* Uint8ClampedArray.h in Headers */,
                                A8A47467151A825B004123FF /* Unicode.h in Headers */,
+                               A8A47464151A825B004123FF /* UnicodeIcu.h in Headers */,
                                A8A47468151A825B004123FF /* UnicodeMacrosFromICU.h in Headers */,
-                               A8A4746A151A825B004123FF /* UTF8.h in Headers */,
                                A8A4746D151A825B004123FF /* UnionFind.h in Headers */,
                                A8A4746E151A825B004123FF /* UnusedParam.h in Headers */,
-                               A8A47470151A825B004123FF /* ParsedURL.h in Headers */,
-                               A8A47471151A825B004123FF /* URLString.h in Headers */,
-                               A8A47472151A825B004123FF /* RawURLBuffer.h in Headers */,
                                A8A47473151A825B004123FF /* URLBuffer.h in Headers */,
                                A8A47475151A825B004123FF /* URLCharacterTypes.h in Headers */,
                                A8A47476151A825B004123FF /* URLComponent.h in Headers */,
                                A8A47479151A825B004123FF /* URLParser.h in Headers */,
                                A8A4747A151A825B004123FF /* URLQueryCanonicalizer.h in Headers */,
                                A8A4747C151A825B004123FF /* URLSegments.h in Headers */,
+                               A8A47471151A825B004123FF /* URLString.h in Headers */,
+                               A8A4746A151A825B004123FF /* UTF8.h in Headers */,
+                               A8A473B9151A825B004123FF /* utils.h in Headers */,
                                A8A4747D151A825B004123FF /* ValueCheck.h in Headers */,
                                A8A4747E151A825B004123FF /* Vector.h in Headers */,
                                A8A4747F151A825B004123FF /* VectorTraits.h in Headers */,
                                A8A47480151A825B004123FF /* VMTags.h in Headers */,
+                               A8A47446151A825B004123FF /* WTFString.h in Headers */,
                                A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
-                               A8A4748C151A8264004123FF /* config.h in Headers */,
-                               143F61201565F0F900DB514A /* RAMSize.h in Headers */,
-                               0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */,
-                               8134013915B092FD001FF0B8 /* Base64.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A8A47381151A825B004123FF /* ArrayBuffer.cpp in Sources */,
                                A8A47383151A825B004123FF /* ArrayBufferView.cpp in Sources */,
                                A8A47386151A825B004123FF /* Assertions.cpp in Sources */,
+                               A8A47435151A825B004123FF /* AtomicString.cpp in Sources */,
+                               8134013815B092FD001FF0B8 /* Base64.cpp in Sources */,
+                               A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */,
+                               A8A473AA151A825B004123FF /* bignum.cc in Sources */,
+                               A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */,
                                A8A4738B151A825B004123FF /* BitVector.cpp in Sources */,
+                               A8A473AC151A825B004123FF /* cached-powers.cc in Sources */,
+                               A8A47460151A825B004123FF /* CollatorDefault.cpp in Sources */,
+                               A8A47463151A825B004123FF /* CollatorICU.cpp in Sources */,
                                A8A4739A151A825B004123FF /* CryptographicallyRandomNumber.cpp in Sources */,
+                               A8A47439151A825B004123FF /* CString.cpp in Sources */,
                                A8A4739C151A825B004123FF /* CurrentTime.cpp in Sources */,
                                A8A4739E151A825B004123FF /* DataLog.cpp in Sources */,
                                A8A473A0151A825B004123FF /* DateMath.cpp in Sources */,
                                A8A473A2151A825B004123FF /* DecimalNumber.cpp in Sources */,
-                               A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */,
-                               A8A473AA151A825B004123FF /* bignum.cc in Sources */,
-                               A8A473AC151A825B004123FF /* cached-powers.cc in Sources */,
                                A8A473AE151A825B004123FF /* diy-fp.cc in Sources */,
                                A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
-                               A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
-                               A8A473B5151A825B004123FF /* fixed-dtoa.cc in Sources */,
-                               A8A473B7151A825B004123FF /* strtod.cc in Sources */,
                                A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
                                A8A473BC151A825B004123FF /* DynamicAnnotations.cpp in Sources */,
+                               A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
                                A8A473C3151A825B004123FF /* FastMalloc.cpp in Sources */,
+                               A8A473B5151A825B004123FF /* fixed-dtoa.cc in Sources */,
                                A8A473D8151A825B004123FF /* HashTable.cpp in Sources */,
-                               A8A473E4151A825B004123FF /* MainThreadMac.mm in Sources */,
                                A8A473E5151A825B004123FF /* MainThread.cpp in Sources */,
+                               A8A473E4151A825B004123FF /* MainThreadMac.mm in Sources */,
                                A8A473E9151A825B004123FF /* MD5.cpp in Sources */,
                                A8A473EC151A825B004123FF /* MetaAllocator.cpp in Sources */,
                                A8A473F2151A825B004123FF /* NullPtr.cpp in Sources */,
                                A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */,
                                A8A47400151A825B004123FF /* PageAllocationAligned.cpp in Sources */,
                                A8A47402151A825B004123FF /* PageBlock.cpp in Sources */,
+                               A8A4746F151A825B004123FF /* ParsedURL.cpp in Sources */,
+                               143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */,
                                A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */,
                                A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */,
                                A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
                                A8A47425151A825B004123FF /* SizeLimits.cpp in Sources */,
                                A8A47427151A825B004123FF /* StackBounds.cpp in Sources */,
-                               A8A4742B151A825B004123FF /* StringExtras.cpp in Sources */,
-                               A8A47431151A825B004123FF /* TCSystemAlloc.cpp in Sources */,
-                               A8A47435151A825B004123FF /* AtomicString.cpp in Sources */,
-                               A8A47439151A825B004123FF /* CString.cpp in Sources */,
                                A8A4743C151A825B004123FF /* StringBuilder.cpp in Sources */,
+                               A8A4742B151A825B004123FF /* StringExtras.cpp in Sources */,
                                A8A47440151A825B004123FF /* StringImpl.cpp in Sources */,
                                A8A47443151A825B004123FF /* StringStatics.cpp in Sources */,
-                               4330F38F15745B0500AAFA8F /* URLString.cpp in Sources */,
-                               A8A47445151A825B004123FF /* WTFString.cpp in Sources */,
+                               A8A473B7151A825B004123FF /* strtod.cc in Sources */,
+                               A8A47431151A825B004123FF /* TCSystemAlloc.cpp in Sources */,
                                A8A47448151A825B004123FF /* ThreadIdentifierDataPthreads.cpp in Sources */,
                                A8A4744A151A825B004123FF /* Threading.cpp in Sources */,
                                A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */,
-                               A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */,
                                A8A47458151A825B004123FF /* TypeTraits.cpp in Sources */,
-                               A8A47460151A825B004123FF /* CollatorDefault.cpp in Sources */,
-                               A8A47463151A825B004123FF /* CollatorICU.cpp in Sources */,
-                               A8A47469151A825B004123FF /* UTF8.cpp in Sources */,
-                               A8A4746F151A825B004123FF /* ParsedURL.cpp in Sources */,
                                A8A47474151A825B004123FF /* URLCharacterTypes.cpp in Sources */,
                                A8A47477151A825B004123FF /* URLEscape.cpp in Sources */,
                                A8A4747B151A825B004123FF /* URLSegments.cpp in Sources */,
+                               4330F38F15745B0500AAFA8F /* URLString.cpp in Sources */,
+                               A8A47469151A825B004123FF /* UTF8.cpp in Sources */,
+                               A8A47445151A825B004123FF /* WTFString.cpp in Sources */,
                                A8A47486151A825B004123FF /* WTFThreadData.cpp in Sources */,
-                               143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */,
-                               8134013815B092FD001FF0B8 /* Base64.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 9d34d45..bd29149 100644 (file)
@@ -28,6 +28,7 @@ SET(WTF_HEADERS
     FixedArray.h
     Forward.h
     GetPtr.h
+    GregorianDateTime.h
     HashCountedSet.h
     HashFunctions.h
     HashIterators.h
diff --git a/Source/WTF/wtf/GregorianDateTime.h b/Source/WTF/wtf/GregorianDateTime.h
new file mode 100644 (file)
index 0000000..2b4fc35
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 WTF_GregorianDateTime_h
+#define WTF_GregorianDateTime_h
+
+#include <wtf/text/CString.h>
+
+namespace WTF {
+
+class GregorianDateTime {
+    WTF_MAKE_NONCOPYABLE(GregorianDateTime);
+public:
+    GregorianDateTime()
+        : m_year(0)
+        , m_month(0)
+        , m_yearDay(0)
+        , m_monthDay(0)
+        , m_weekDay(0)
+        , m_hour(0)
+        , m_minute(0)
+        , m_second(0)
+        , m_utcOffset(0)
+        , m_isDST(0)
+    {
+    }
+
+    inline int year() const { return m_year; }
+    inline int month() const { return m_month; }
+    inline int yearDay() const { return m_yearDay; }
+    inline int monthDay() const { return m_monthDay; }
+    inline int weekDay() const { return m_weekDay; }
+    inline int hour() const { return m_hour; }
+    inline int minute() const { return m_minute; }
+    inline int second() const { return m_second; }
+    inline int utcOffset() const { return m_utcOffset; }
+    inline int isDST() const { return m_isDST; }
+
+    inline void setYear(int year) { m_year = year; }
+    inline void setMonth(int month) { m_month = month; }
+    inline void setYearDay(int yearDay) { m_yearDay = yearDay; }
+    inline void setMonthDay(int monthDay) { m_monthDay = monthDay; }
+    inline void setWeekDay(int weekDay) { m_weekDay = weekDay; }
+    inline void setHour(int hour) { m_hour = hour; }
+    inline void setMinute(int minute) { m_minute = minute; }
+    inline void setSecond(int second) { m_second = second; }
+    inline void setUtcOffset(int utcOffset) { m_utcOffset = utcOffset; }
+    inline void setIsDST(int isDST) { m_isDST = isDST; }
+
+    operator tm() const
+    {
+        tm ret;
+        memset(&ret, 0, sizeof(ret));
+
+        ret.tm_year = m_year;
+        ret.tm_mon = m_month;
+        ret.tm_yday = m_yearDay;
+        ret.tm_mday = m_monthDay;
+        ret.tm_wday = m_weekDay;
+        ret.tm_hour = m_hour;
+        ret.tm_min = m_minute;
+        ret.tm_sec = m_second;
+        ret.tm_isdst = m_isDST;
+
+#if HAVE(TM_GMTOFF)
+        ret.tm_gmtoff = static_cast<long>(m_utcOffset);
+#endif
+
+        return ret;
+    }
+
+    void copyFrom(const GregorianDateTime& other)
+    {
+        m_year = other.m_year;
+        m_month = other.m_month;
+        m_yearDay = other.m_yearDay;
+        m_monthDay = other.m_monthDay;
+        m_weekDay = other.m_weekDay;
+        m_hour = other.m_hour;
+        m_minute = other.m_minute;
+        m_second = other.m_second;
+        m_utcOffset = other.m_utcOffset;
+        m_isDST = other.m_isDST;
+    }
+
+private:
+    int m_year;
+    int m_month;
+    int m_yearDay;
+    int m_monthDay;
+    int m_weekDay;
+    int m_hour;
+    int m_minute;
+    int m_second;
+    int m_utcOffset;
+    int m_isDST;
+};
+
+} // namespace WTF
+
+using WTF::GregorianDateTime;
+
+#endif // WTF_GregorianDateTime_h
index 5d52b4b..afb757d 100644 (file)
@@ -1,3 +1,21 @@
+2012-07-23  Patrick Gansterer  <paroga@webkit.org>
+
+        Move GregorianDateTime from JSC to WTF namespace
+        https://bugs.webkit.org/show_bug.cgi?id=91948
+
+        Reviewed by Geoffrey Garen.
+
+        Moving GregorianDateTime into the WTF namespace allows us to us to
+        use it in WebCore too. The new class has the same behaviour as the
+        old struct. Only the unused timeZone member has been removed.
+
+        * bridge/qt/qt_runtime.cpp:
+        (JSC::Bindings::convertValueToQVariant):
+        (JSC::Bindings::convertQVariantToValue):
+        * bridge/qt/qt_runtime_qt4.cpp:
+        (JSC::Bindings::convertValueToQVariant):
+        (JSC::Bindings::convertQVariantToValue):
+
 2012-07-23  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Move layoutTestMode to WebCore
index 040d51f..5c03d29 100644 (file)
@@ -504,13 +504,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 GregorianDateTime gdt;
                 msToGregorianDateTime(exec, date->internalNumber(), true, gdt);
                 if (hint == QMetaType::QDateTime) {
-                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
                     dist = 0;
                 } else if (hint == QMetaType::QDate) {
-                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
                     dist = 1;
                 } else {
-                    ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second);
+                    ret = QTime(gdt.hour() + 1900, gdt.minute(), gdt.second());
                     dist = 2;
                 }
             } else if (type == Number) {
@@ -518,13 +518,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 GregorianDateTime gdt;
                 msToGregorianDateTime(exec, b, true, gdt);
                 if (hint == QMetaType::QDateTime) {
-                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
                     dist = 6;
                 } else if (hint == QMetaType::QDate) {
-                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
                     dist = 8;
                 } else {
-                    ret = QTime(gdt.hour, gdt.minute, gdt.second);
+                    ret = QTime(gdt.hour(), gdt.minute(), gdt.second());
                     dist = 10;
                 }
 #ifndef QT_NO_DATESTRING
@@ -874,13 +874,13 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
 
         // Dates specified this way are in local time (we convert DateTimes above)
         GregorianDateTime dt;
-        dt.year = date.year() - 1900;
-        dt.month = date.month() - 1;
-        dt.monthDay = date.day();
-        dt.hour = time.hour();
-        dt.minute = time.minute();
-        dt.second = time.second();
-        dt.isDST = -1;
+        dt.setYear(date.year() - 1900);
+        dt.setMonth(date.month() - 1);
+        dt.setMonthDay(date.day());
+        dt.setHour(time.hour());
+        dt.setMinute(time.minute());
+        dt.setSecond(time.second());
+        dt.setIsDST(-1);
         double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false);
 
         return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));
index 9682f14..c3890af 100644 (file)
@@ -504,13 +504,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 GregorianDateTime gdt;
                 msToGregorianDateTime(exec, date->internalNumber(), true, gdt);
                 if (hint == QMetaType::QDateTime) {
-                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
                     dist = 0;
                 } else if (hint == QMetaType::QDate) {
-                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
                     dist = 1;
                 } else {
-                    ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second);
+                    ret = QTime(gdt.hour() + 1900, gdt.minute(), gdt.second());
                     dist = 2;
                 }
             } else if (type == Number) {
@@ -518,13 +518,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
                 GregorianDateTime gdt;
                 msToGregorianDateTime(exec, b, true, gdt);
                 if (hint == QMetaType::QDateTime) {
-                    ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
+                    ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
                     dist = 6;
                 } else if (hint == QMetaType::QDate) {
-                    ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
+                    ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
                     dist = 8;
                 } else {
-                    ret = QTime(gdt.hour, gdt.minute, gdt.second);
+                    ret = QTime(gdt.hour(), gdt.minute(), gdt.second());
                     dist = 10;
                 }
 #ifndef QT_NO_DATESTRING
@@ -874,13 +874,13 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
 
         // Dates specified this way are in local time (we convert DateTimes above)
         GregorianDateTime dt;
-        dt.year = date.year() - 1900;
-        dt.month = date.month() - 1;
-        dt.monthDay = date.day();
-        dt.hour = time.hour();
-        dt.minute = time.minute();
-        dt.second = time.second();
-        dt.isDST = -1;
+        dt.setYear(date.year() - 1900);
+        dt.setMonth(date.month() - 1);
+        dt.setMonthDay(date.day());
+        dt.setHour(time.hour());
+        dt.setMinute(time.minute());
+        dt.setSecond(time.second());
+        dt.setIsDST(-1);
         double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false);
 
         return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));