Reviewed by Adam, Geoff, Darin.

       Fixed displaying the UTC offset and time zone string, as well as renamed the GregorianDateTime structure and clean up. 

        * ChangeLog:
        * kjs/DateMath.cpp:
        (KJS::getUTCOffset):
        (KJS::getDSTOffsetSimple):
        (KJS::gregorianDateTimeToMS):
        (KJS::msToGregorianDateTime):
        * kjs/DateMath.h:
        (KJS::GregorianDateTime::GregorianDateTime):
        (KJS::GregorianDateTime::~GregorianDateTime):
        (KJS::GregorianDateTime::toTM):
        * kjs/date_object.cpp:
        (KJS::gmtoffset):
        (KJS::formatDate):
        (KJS::formatDateUTCVariant):
        (KJS::formatTime):
        (KJS::fillStructuresUsingTimeArgs):
        (KJS::fillStructuresUsingDateArgs):
        (KJS::DateInstance::getTime):
        (KJS::DateInstance::getUTCTime):
        (KJS::DateProtoFunc::callAsFunction):
        (KJS::DateObjectImp::construct):
        (KJS::DateObjectImp::callAsFunction):
        (KJS::DateObjectFuncImp::callAsFunction):
        (KJS::parseDate):
        * kjs/date_object.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@17031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 445af4a..1942c98 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,44 @@
+2006-10-13  Kevin McCullough  <KMcCullough@apple.com>
+
+        Reviewed by Adam, Geoff, Darin.
+
+       Fixed displaying the UTC offset and time zone string, as well as renamed the GregorianDateTime structure and clean up. 
+
+        * ChangeLog:
+        * kjs/DateMath.cpp:
+        (KJS::getUTCOffset):
+        (KJS::getDSTOffsetSimple):
+        (KJS::gregorianDateTimeToMS):
+        (KJS::msToGregorianDateTime):
+        * kjs/DateMath.h:
+        (KJS::GregorianDateTime::GregorianDateTime):
+        (KJS::GregorianDateTime::~GregorianDateTime):
+        (KJS::GregorianDateTime::toTM):
+        * kjs/date_object.cpp:
+        (KJS::gmtoffset):
+        (KJS::formatDate):
+        (KJS::formatDateUTCVariant):
+        (KJS::formatTime):
+        (KJS::fillStructuresUsingTimeArgs):
+        (KJS::fillStructuresUsingDateArgs):
+        (KJS::DateInstance::getTime):
+        (KJS::DateInstance::getUTCTime):
+        (KJS::DateProtoFunc::callAsFunction):
+        (KJS::DateObjectImp::construct):
+        (KJS::DateObjectImp::callAsFunction):
+        (KJS::DateObjectFuncImp::callAsFunction):
+        (KJS::parseDate):
+        * kjs/date_object.h:
+
+2006-10-13  Kevin McCullough  <KMcCullough@apple.com>
+
+        Reviewed by Adam.
+
+        Gets JavaScripCore tests running on windows.
+
+        * Scripts/run-javascriptcore-tests:
+        * Scripts/webkitdirs.pm:
+
 2006-10-12  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Maciej.
diff --git a/JavaScriptCore/kjs/DateMath.cpp b/JavaScriptCore/kjs/DateMath.cpp
index 64a1006..4a9617d 100644
--- a/JavaScriptCore/kjs/DateMath.cpp
+++ b/JavaScriptCore/kjs/DateMath.cpp
@@ -319,15 +319,15 @@
     static double utcOffset;
     static bool utcOffsetInitialized = false;
     if (!utcOffsetInitialized) {
-        struct ::tm ltime;
+        tm localt;
 
-        memset(&ltime, 0, sizeof(ltime));
+        memset(&localt, 0, sizeof(localt));
         
         // get the difference between this time zone and GMT 
-        ltime.tm_mday = 2;
-        ltime.tm_year = 70;
+        localt.tm_mday = 2;
+        localt.tm_year = 70;
 
-        utcOffset = mktime(&ltime) - (hoursPerDay * secondsPerHour);
+        utcOffset = mktime(&localt) - (hoursPerDay * secondsPerHour);
         utcOffset *= -msPerSecond;
 
         utcOffsetInitialized = true;
@@ -356,14 +356,14 @@
     // FIXME: time_t has a potential problem in 2038
     time_t localTime = static_cast<time_t>(localTimeSeconds);
 
-    struct ::tm tm;
+    tm localTM;
     #if PLATFORM(WIN_OS)
-    localtime_s(&tm, &localTime);
+    localtime_s(&localTM, &localTime);
     #else
-    localtime_r(&localTime, &tm);
+    localtime_r(&localTime, &localTM);
     #endif
     
-    double diff = ((tm.tm_hour - offsetHour) * secondsPerHour) + ((tm.tm_min - offsetMinute) * 60);
+    double diff = ((localTM.tm_hour - offsetHour) * secondsPerHour) + ((localTM.tm_min - offsetMinute) * 60);
 
     if(diff < 0)
         diff += secondsPerDay;
@@ -391,11 +391,11 @@
     return getDSTOffsetSimple(ms / usecPerMsec);
 }
 
-double dateToMS(const tm& t, double milliSeconds, bool inputIsUTC)
+double gregorianDateTimeToMS(const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
 {
 
-    int day = dateToDayInYear(t.tm_year + 1900, t.tm_mon, t.tm_mday);
-    double ms = timeToMS(t.tm_hour, t.tm_min, t.tm_sec, milliSeconds);
+    int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);
+    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
     double result = (day * msPerDay) + ms;
 
     if(!inputIsUTC) { // convert to UTC
@@ -406,7 +406,7 @@
     return result;
 }
 
-void msToTM(double ms, bool outputIsUTC, struct tm& tm)
+void msToGregorianDateTime(double ms, bool outputIsUTC, struct GregorianDateTime& tm)
 {
     // input is UTC
     double dstOff = 0.0;
@@ -416,65 +416,18 @@
         ms += dstOff + getUTCOffset();
     }
 
-    tm.tm_sec   =  msToSeconds(ms);
-    tm.tm_min   =  msToMinutes(ms);
-    tm.tm_hour  =  msToHours(ms);
-    tm.tm_wday  =  msToWeekDay(ms);
-    tm.tm_mday  =  msToDayInMonth(ms);
-    tm.tm_yday  =  dayInYear(ms, msToYear(ms));
-    tm.tm_mon   =  msToMonth(ms);
-    tm.tm_year  =  msToYear(ms) - 1900;
-    tm.tm_isdst =  dstOff != 0.0;
+    tm.second   =  msToSeconds(ms);
+    tm.minute   =  msToMinutes(ms);
+    tm.hour     =  msToHours(ms);
+    tm.weekDay  =  msToWeekDay(ms);
+    tm.monthDay =  msToDayInMonth(ms);
+    tm.yearDay  =  dayInYear(ms, msToYear(ms));
+    tm.month    =  msToMonth(ms);
+    tm.year     =  msToYear(ms) - 1900;
+    tm.isDST =  dstOff != 0.0;
 
-    tm.tm_gmtoff = static_cast<long>((dstOff + getUTCOffset()) / usecPerMsec);
-    tm.tm_zone = 0;
-}
-
-// converting between the two tm structures
-tm tmToKJStm(const struct ::tm& inTm)
-{
-    struct tm ret;
-    memset(&ret, 0, sizeof(ret));
-
-    ret.tm_sec   =  inTm.tm_sec;
-    ret.tm_min   =  inTm.tm_min;
-    ret.tm_hour  =  inTm.tm_hour;
-    ret.tm_wday  =  inTm.tm_wday;
-    ret.tm_mday  =  inTm.tm_mday;
-    ret.tm_yday  =  inTm.tm_yday;
-    ret.tm_mon   =  inTm.tm_mon;
-    ret.tm_year  =  inTm.tm_year;
-    ret.tm_isdst =  inTm.tm_isdst;
-
-#if !PLATFORM(WIN_OS)
-    ret.tm_gmtoff = inTm.tm_gmtoff;
-    ret.tm_zone = inTm.tm_zone;
-#endif
-
-    return ret;
-}
-
-::tm KJStmToTm(const struct tm& inTm)
-{
-    struct ::tm ret;
-    memset(&ret, 0, sizeof(ret));
-
-    ret.tm_sec   =  inTm.tm_sec;
-    ret.tm_min   =  inTm.tm_min;
-    ret.tm_hour  =  inTm.tm_hour;
-    ret.tm_wday  =  inTm.tm_wday;
-    ret.tm_mday  =  inTm.tm_mday;
-    ret.tm_yday  =  inTm.tm_yday;
-    ret.tm_mon   =  inTm.tm_mon;
-    ret.tm_year  =  inTm.tm_year;
-    ret.tm_isdst =  inTm.tm_isdst;
-
-#if !PLATFORM(WIN_OS)
-    ret.tm_gmtoff = inTm.tm_gmtoff;
-    ret.tm_zone = inTm.tm_zone;
-#endif
-
-    return ret;
+    tm.utcOffset = static_cast<long>((dstOff + getUTCOffset()) / usecPerMsec);
+    tm.timeZone = NULL;
 }
 
 }   // namespace KJS
diff --git a/JavaScriptCore/kjs/DateMath.h b/JavaScriptCore/kjs/DateMath.h
index be52645..fb29942 100644
--- a/JavaScriptCore/kjs/DateMath.h
+++ b/JavaScriptCore/kjs/DateMath.h
@@ -47,18 +47,85 @@
 
 // Intentionally overridding the default tm of the system
 // Not all OS' have the same members of their tm's
-struct tm {
-    int tm_sec;
-    int tm_min;
-    int tm_hour;
-    int tm_wday;
-    int tm_mday;
-    int tm_yday;
-    int tm_mon;
-    int tm_year;
-    int tm_isdst;
-    long tm_gmtoff;
-    char* tm_zone;
+struct GregorianDateTime {
+    GregorianDateTime()
+    {
+        second = 0;
+        minute = 0;
+        hour = 0;
+        weekDay = 0;
+        monthDay = 0;
+        yearDay = 0;
+        month = 0;
+        year = 0;
+        isDST = 0;
+        utcOffset = 0;
+        timeZone = NULL;
+    }
+
+    ~GregorianDateTime()
+    {
+        if (timeZone) 
+            delete timeZone;
+    }
+    
+    GregorianDateTime(const tm& inTm)
+        : second(inTm.tm_sec)
+        , minute(inTm.tm_min)
+        , hour(inTm.tm_hour)
+        , weekDay(inTm.tm_wday)
+        , monthDay(inTm.tm_mday)
+        , yearDay(inTm.tm_yday)
+        , month(inTm.tm_mon)
+        , year(inTm.tm_year)
+        , isDST(inTm.tm_isdst)
+    {
+#if !PLATFORM(WIN_OS)
+        utcOffset = static_cast<int>(inTm.tm_gmtoff);
+
+        int inZoneSize = strlen(inTm.tm_zone) + 1;
+        timeZone = new char[inZoneSize];
+        strncpy(timeZone, inTm.tm_zone, inZoneSize);
+#else
+        utcOffset = 0;
+        timeZone = NULL;
+#endif
+    }
+
+    tm toTM() 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 !PLATFORM(WIN_OS)
+        ret.tm_gmtoff = static_cast<long>(utcOffset);
+        ret.tm_zone = timeZone;
+#endif
+
+        return ret;
+    }
+
+    int second;
+    int minute;
+    int hour;
+    int weekDay;
+    int monthDay;
+    int yearDay;
+    int month;
+    int year;
+    int  isDST;
+    int utcOffset;
+    char* timeZone;
 };
 
 // Constants //
@@ -75,13 +142,10 @@
 const double msPerHour = 60.0 * 60.0 * 1000.0;
 
 // Exported Functions //
-void msToTM(double, bool outputIsUTC, struct tm& );
-double dateToMS(const tm&, double, bool inputIsUTC);
+void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&);
+double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);
 double getUTCOffset();
 
-tm tmToKJStm(const struct ::tm&);
-::tm KJStmToTm(const struct tm&);
-
 }   //namespace KJS
 
 #endif // DateMath_h
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 218b2c3..f89fc23 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -65,9 +65,9 @@
 static double parseDate(const UString&);
 static double timeClip(double);
 
-inline int gmtoffset(const tm& t)
+inline int gmtoffset(const GregorianDateTime& t)
 {
-    return static_cast<int>(t.tm_gmtoff);
+    return t.utcOffset;
 }
 
 
@@ -156,42 +156,42 @@
 
 #endif // PLATFORM(MAC)
 
-static UString formatDate(const tm &t)
+static UString formatDate(const GregorianDateTime &t)
 {
     char buffer[100];
     snprintf(buffer, sizeof(buffer), "%s %s %02d %04d",
-        weekdayName[(t.tm_wday + 6) % 7],
-        monthName[t.tm_mon], t.tm_mday, t.tm_year + 1900);
+        weekdayName[(t.weekDay + 6) % 7],
+        monthName[t.month], t.monthDay, t.year + 1900);
     return buffer;
 }
 
-static UString formatDateUTCVariant(const tm &t)
+static UString formatDateUTCVariant(const GregorianDateTime &t)
 {
     char buffer[100];
     snprintf(buffer, sizeof(buffer), "%s, %02d %s %04d",
-        weekdayName[(t.tm_wday + 6) % 7],
-        t.tm_mday, monthName[t.tm_mon], t.tm_year + 1900);
+        weekdayName[(t.weekDay + 6) % 7],
+        t.monthDay, monthName[t.month], t.year + 1900);
     return buffer;
 }
 
-static UString formatTime(const tm &t, bool utc)
+static UString formatTime(const GregorianDateTime &t, bool utc)
 {
     char buffer[100];
     if (utc) {
-        snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.tm_hour, t.tm_min, t.tm_sec);
+        snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.hour, t.minute, t.second);
     } else {
         int offset = abs(gmtoffset(t));
         char tzname[70];
-        struct ::tm gtm = KJStmToTm(t);
+        struct ::tm gtm = t.toTM();
         strftime(tzname, sizeof(tzname), "%Z", &gtm);
 
         if (tzname) {
             snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d (%s)",
-                t.tm_hour, t.tm_min, t.tm_sec,
+                t.hour, t.minute, t.second,
                 gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, tzname);
         } else {
             snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d",
-                t.tm_hour, t.tm_min, t.tm_sec,
+                t.hour, t.minute, t.second,
                 gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
         }
     }
@@ -202,7 +202,7 @@
 // ms (representing milliseconds) and t (representing the rest of the date structure) appropriately.
 //
 // Format of member function: f([hour,] [min,] [sec,] [ms])
-static void fillStructuresUsingTimeArgs(ExecState *exec, const List &args, int maxArgs, double *ms, tm *t)
+static void fillStructuresUsingTimeArgs(ExecState *exec, const List &args, int maxArgs, double *ms, GregorianDateTime *t)
 {
     double milliseconds = 0;
     int idx = 0;
@@ -214,19 +214,19 @@
 
     // hours
     if (maxArgs >= 4 && idx < numArgs) {
-        t->tm_hour = 0;
+        t->hour = 0;
         milliseconds += args[idx++]->toInt32(exec) * msPerHour;
     }
 
     // minutes
     if (maxArgs >= 3 && idx < numArgs) {
-        t->tm_min = 0;
+        t->minute = 0;
         milliseconds += args[idx++]->toInt32(exec) * msPerMinute;
     }
     
     // seconds
     if (maxArgs >= 2 && idx < numArgs) {
-        t->tm_sec = 0;
+        t->second = 0;
         milliseconds += args[idx++]->toInt32(exec) * msPerSecond;
     }
     
@@ -244,7 +244,7 @@
 // ms (representing milliseconds) and t (representing the rest of the date structure) appropriately.
 //
 // Format of member function: f([years,] [months,] [days])
-static void fillStructuresUsingDateArgs(ExecState *exec, const List &args, int maxArgs, double *ms, tm *t)
+static void fillStructuresUsingDateArgs(ExecState *exec, const List &args, int maxArgs, double *ms, GregorianDateTime *t)
 {
     int idx = 0;
     int numArgs = args.size();
@@ -255,15 +255,15 @@
   
     // years
     if (maxArgs >= 3 && idx < numArgs)
-        t->tm_year = args[idx++]->toInt32(exec) - 1900;
+        t->year = args[idx++]->toInt32(exec) - 1900;
   
     // months
     if (maxArgs >= 2 && idx < numArgs)
-        t->tm_mon = args[idx++]->toInt32(exec);
+        t->month = args[idx++]->toInt32(exec);
   
     // days
     if (idx < numArgs) {
-        t->tm_mday = 0;
+        t->monthDay = 0;
         *ms += args[idx]->toInt32(exec) * msPerDay;
     }
 }
@@ -277,24 +277,24 @@
 {
 }
 
-bool DateInstance::getTime(tm &t, int &offset) const
+bool DateInstance::getTime(GregorianDateTime &t, int &offset) const
 {
     double milli = internalValue()->getNumber();
     if (isNaN(milli))
         return false;
     
-    msToTM(milli, false, t);
+    msToGregorianDateTime(milli, false, t);
     offset = gmtoffset(t);
     return true;
 }
 
-bool DateInstance::getUTCTime(tm &t) const
+bool DateInstance::getUTCTime(GregorianDateTime &t) const
 {
     double milli = internalValue()->getNumber();
     if (isNaN(milli))
         return false;
     
-    msToTM(milli, true, t);
+    msToGregorianDateTime(milli, true, t);
     return true;
 }
 
@@ -304,8 +304,8 @@
     if (isNaN(milli))
         return false;
     
-    tm t;
-    msToTM(milli, false, t);
+    GregorianDateTime t;
+    msToGregorianDateTime(milli, false, t);
     offset = gmtoffset(t);
     return true;
 }
@@ -452,8 +452,8 @@
   double secs = floor(milli / msPerSecond);
   double ms = milli - secs * msPerSecond;
 
-  tm t;
-  msToTM(milli, utc, t);
+  GregorianDateTime t;
+  msToGregorianDateTime(milli, utc, t);
 
   switch (id) {
   case ToString:
@@ -504,22 +504,22 @@
   case GetYear:
     // IE returns the full year even in getYear.
     if (exec->dynamicInterpreter()->compatMode() == Interpreter::IECompat)
-      return jsNumber(1900 + t.tm_year);
-    return jsNumber(t.tm_year);
+      return jsNumber(1900 + t.year);
+    return jsNumber(t.year);
   case GetFullYear:
-    return jsNumber(1900 + t.tm_year);
+    return jsNumber(1900 + t.year);
   case GetMonth:
-    return jsNumber(t.tm_mon);
+    return jsNumber(t.month);
   case GetDate:
-    return jsNumber(t.tm_mday);
+    return jsNumber(t.monthDay);
   case GetDay:
-    return jsNumber(t.tm_wday);
+    return jsNumber(t.weekDay);
   case GetHours:
-    return jsNumber(t.tm_hour);
+    return jsNumber(t.hour);
   case GetMinutes:
-    return jsNumber(t.tm_min);
+    return jsNumber(t.minute);
   case GetSeconds:
-    return jsNumber(t.tm_sec);
+    return jsNumber(t.second);
   case GetMilliSeconds:
     return jsNumber(ms);
   case GetTimezoneOffset:
@@ -551,14 +551,14 @@
     fillStructuresUsingDateArgs(exec, args, 3, &ms, &t);
     break;
   case SetYear:
-    t.tm_year = (args[0]->toInt32(exec) > 99 || args[0]->toInt32(exec) < 0) ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
+    t.year = (args[0]->toInt32(exec) > 99 || args[0]->toInt32(exec) < 0) ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
     break;
   }
 
   if (id == SetYear || id == SetMilliSeconds || id == SetSeconds ||
       id == SetMinutes || id == SetHours || id == SetDate ||
       id == SetMonth || id == SetFullYear ) {
-    result = jsNumber(dateToMS(t, ms, utc));
+    result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
     thisDateObj->setInternalValue(result);
   }
   
@@ -634,18 +634,18 @@
         || (numArgs >= 7 && isNaN(args[6]->toNumber(exec)))) {
       value = NaN;
     } else {
-      tm t;
+      GregorianDateTime t;
       memset(&t, 0, sizeof(t));
       int year = args[0]->toInt32(exec);
-      t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
-      t.tm_mon = args[1]->toInt32(exec);
-      t.tm_mday = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
-      t.tm_hour = (numArgs >= 4) ? args[3]->toInt32(exec) : 0;
-      t.tm_min = (numArgs >= 5) ? args[4]->toInt32(exec) : 0;
-      t.tm_sec = (numArgs >= 6) ? args[5]->toInt32(exec) : 0;
-      t.tm_isdst = -1;
+      t.year = (year >= 0 && year <= 99) ? year : year - 1900;
+      t.month = args[1]->toInt32(exec);
+      t.monthDay = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
+      t.hour = (numArgs >= 4) ? args[3]->toInt32(exec) : 0;
+      t.minute = (numArgs >= 5) ? args[4]->toInt32(exec) : 0;
+      t.second = (numArgs >= 6) ? args[5]->toInt32(exec) : 0;
+      t.isDST = -1;
       double ms = (numArgs >= 7) ? roundValue(exec, args[6]) : 0;
-      value = dateToMS(t, ms, false);
+      value = gregorianDateTimeToMS(t, ms, false);
     }
   }
   
@@ -658,7 +658,7 @@
 JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/)
 {
     time_t t = time(0);
-    tm ts = tmToKJStm(*localtime(&t));
+    GregorianDateTime ts(*localtime(&t));
     return jsString(formatDate(ts) + " " + formatTime(ts, false));
 }
 
@@ -688,17 +688,17 @@
       return jsNaN();
     }
 
-    tm t;
+    GregorianDateTime t;
     memset(&t, 0, sizeof(t));
     int year = args[0]->toInt32(exec);
-    t.tm_year = (year >= 0 && year <= 99) ? year : year - 1900;
-    t.tm_mon = args[1]->toInt32(exec);
-    t.tm_mday = (n >= 3) ? args[2]->toInt32(exec) : 1;
-    t.tm_hour = (n >= 4) ? args[3]->toInt32(exec) : 0;
-    t.tm_min = (n >= 5) ? args[4]->toInt32(exec) : 0;
-    t.tm_sec = (n >= 6) ? args[5]->toInt32(exec) : 0;
+    t.year = (year >= 0 && year <= 99) ? year : year - 1900;
+    t.month = args[1]->toInt32(exec);
+    t.monthDay = (n >= 3) ? args[2]->toInt32(exec) : 1;
+    t.hour = (n >= 4) ? args[3]->toInt32(exec) : 0;
+    t.minute = (n >= 5) ? args[4]->toInt32(exec) : 0;
+    t.second = (n >= 6) ? args[5]->toInt32(exec) : 0;
     double ms = (n >= 7) ? roundValue(exec, args[6]) : 0;
-    return jsNumber(dateToMS(t, ms, true));
+    return jsNumber(gregorianDateTimeToMS(t, ms, true));
   }
 }
 
@@ -1055,18 +1055,18 @@
 
     // fall back to local timezone
     if (!haveTZ) {
-        tm t;
+        GregorianDateTime t;
         memset(&t, 0, sizeof(tm));
-        t.tm_mday = day;
-        t.tm_mon = month;
-        t.tm_year = year - 1900;
-        t.tm_isdst = -1;
-        t.tm_sec = second;
-        t.tm_min = minute;
-        t.tm_hour = hour;
+        t.monthDay = day;
+        t.month = month;
+        t.year = year - 1900;
+        t.isDST = -1;
+        t.second = second;
+        t.minute = minute;
+        t.hour = hour;
 
-        // Use our dateToMS() rather than mktime() as the latter can't handle the full year range.
-        return dateToMS(t, 0, false);
+        // Use our gregorianDateTimeToMS() rather than mktime() as the latter can't handle the full year range.
+        return gregorianDateTimeToMS(t, 0, false);
     }
 
     return (ymdhmsToSeconds(year, month + 1, day, hour, minute, second) - (offset * 60.0)) * msPerSecond;
diff --git a/JavaScriptCore/kjs/date_object.h b/JavaScriptCore/kjs/date_object.h
index deaaa47..dcfba66 100644
--- a/JavaScriptCore/kjs/date_object.h
+++ b/JavaScriptCore/kjs/date_object.h
@@ -26,7 +26,7 @@
 
 namespace KJS {
 
-    struct tm;
+    struct GregorianDateTime;
 
     class FunctionPrototype;
     class ObjectPrototype;
@@ -35,10 +35,10 @@
     public:
         DateInstance(JSObject *proto);
         
-        bool getTime(tm &t, int &gmtoffset) const;
-        bool getUTCTime(tm &t) const;
-        bool getTime(double &ms, int &gmtoffset) const;
-        bool getUTCTime(double &ms) const;
+        bool getTime(GregorianDateTime&, int& offset) const;
+        bool getUTCTime(GregorianDateTime&) const;
+        bool getTime(double& milli, int& offset) const;
+        bool getUTCTime(double& milli) const;
         
         virtual const ClassInfo *classInfo() const { return &info; }
         static const ClassInfo info;