Changeset 49886 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Oct 20, 2009, 2:39:43 PM (16 years ago)
Author:
[email protected]
Message:

Refactored DateInstance::msToGregorianDateTime so that a DateInstance's
caller doesn't need to supply the DateInstance's own internal value to
the DateInstance.

Patch by Geoffrey Garen <[email protected]> on 2009-10-20
Reviewed by Sam Weinig.

  • runtime/DateInstance.cpp:

(JSC::DateInstance::getGregorianDateTime): Renamed from "msToGregorianDateTime".

  • runtime/DateInstance.h:
  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate):
(JSC::dateProtoFuncToString):
(JSC::dateProtoFuncToUTCString):
(JSC::dateProtoFuncToISOString):
(JSC::dateProtoFuncToDateString):
(JSC::dateProtoFuncToTimeString):
(JSC::dateProtoFuncToLocaleString):
(JSC::dateProtoFuncToLocaleDateString):
(JSC::dateProtoFuncToLocaleTimeString):
(JSC::dateProtoFuncGetTime):
(JSC::dateProtoFuncGetFullYear):
(JSC::dateProtoFuncGetUTCFullYear):
(JSC::dateProtoFuncToGMTString):
(JSC::dateProtoFuncGetMonth):
(JSC::dateProtoFuncGetUTCMonth):
(JSC::dateProtoFuncGetDate):
(JSC::dateProtoFuncGetUTCDate):
(JSC::dateProtoFuncGetDay):
(JSC::dateProtoFuncGetUTCDay):
(JSC::dateProtoFuncGetHours):
(JSC::dateProtoFuncGetUTCHours):
(JSC::dateProtoFuncGetMinutes):
(JSC::dateProtoFuncGetUTCMinutes):
(JSC::dateProtoFuncGetSeconds):
(JSC::dateProtoFuncGetUTCSeconds):
(JSC::dateProtoFuncGetTimezoneOffset):
(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetYear):
(JSC::dateProtoFuncGetYear): Also renamed "utc" to "outputIsUTC", for clarity.

Location:
trunk/JavaScriptCore/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/DateInstance.cpp

    r49217 r49886  
    6060}
    6161
    62 void DateInstance::msToGregorianDateTime(double milli, bool outputIsUTC, GregorianDateTime& t) const
     62bool DateInstance::getGregorianDateTime(bool outputIsUTC, GregorianDateTime& t) const
    6363{
    6464    if (!m_cache) {
     
    6868    }
    6969
     70    double milli = internalNumber();
     71    if (isnan(milli))
     72        return false;
     73
    7074    if (outputIsUTC) {
    7175        if (m_cache->m_gregorianDateTimeUTCCachedForMS != milli) {
    72             WTF::msToGregorianDateTime(milli, true, m_cache->m_cachedGregorianDateTimeUTC);
     76            WTF::msToGregorianDateTime(internalNumber(), true, m_cache->m_cachedGregorianDateTimeUTC);
    7377            m_cache->m_gregorianDateTimeUTCCachedForMS = milli;
    7478        }
     
    7680    } else {
    7781        if (m_cache->m_gregorianDateTimeCachedForMS != milli) {
    78             WTF::msToGregorianDateTime(milli, false, m_cache->m_cachedGregorianDateTime);
     82            WTF::msToGregorianDateTime(internalNumber(), false, m_cache->m_cachedGregorianDateTime);
    7983            m_cache->m_gregorianDateTimeCachedForMS = milli;
    8084        }
    8185        t.copyFrom(m_cache->m_cachedGregorianDateTime);
    8286    }
     87   
     88    return true;
    8389}
    8490
  • trunk/JavaScriptCore/runtime/DateInstance.h

    r49845 r49886  
    4545        static JS_EXPORTDATA const ClassInfo info;
    4646
    47         void msToGregorianDateTime(double, bool outputIsUTC, WTF::GregorianDateTime&) const;
     47        bool getGregorianDateTime(bool outputIsUTC, WTF::GregorianDateTime&) const;
    4848
    4949        static PassRefPtr<Structure> createStructure(JSValue prototype)
     
    5858        virtual const ClassInfo* classInfo() const { return &info; }
    5959
    60         using JSWrapperObject::internalValue;
    6160
    6261        struct Cache;
  • trunk/JavaScriptCore/runtime/DatePrototype.cpp

    r48836 r49886  
    252252}
    253253
    254 static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList&)
     254static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format, const ArgList&)
    255255{
    256256    GregorianDateTime gregorianDateTime;
    257257    const bool notUTC = false;
    258     dateObject->msToGregorianDateTime(timeInMilliseconds, notUTC, gregorianDateTime);
     258    if (!dateObject->getGregorianDateTime(outputIsUTC, gregorianDateTime))
     259        return jsNontrivialString(exec, "Invalid Date");
    259260    return formatLocaleDate(exec, gregorianDateTime, format);
    260261}
     
    421422        return throwError(exec, TypeError);
    422423
    423     const bool utc = false;
    424 
    425     DateInstance* thisDateObj = asDateInstance(thisValue);
    426     double milli = thisDateObj->internalNumber();
    427     if (isnan(milli))
     424    const bool outputIsUTC = false;
     425
     426    DateInstance* thisDateObj = asDateInstance(thisValue);
     427
     428    GregorianDateTime t;
     429    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    428430        return jsNontrivialString(exec, "Invalid Date");
    429 
    430     GregorianDateTime t;
    431     thisDateObj->msToGregorianDateTime(milli, utc, t);
    432     return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, utc));
     431    return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, outputIsUTC));
    433432}
    434433
     
    438437        return throwError(exec, TypeError);
    439438
    440     const bool utc = true;
    441 
    442     DateInstance* thisDateObj = asDateInstance(thisValue);
    443     double milli = thisDateObj->internalNumber();
    444     if (isnan(milli))
     439    const bool outputIsUTC = true;
     440
     441    DateInstance* thisDateObj = asDateInstance(thisValue);
     442
     443    GregorianDateTime t;
     444    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    445445        return jsNontrivialString(exec, "Invalid Date");
    446 
    447     GregorianDateTime t;
    448     thisDateObj->msToGregorianDateTime(milli, utc, t);
    449     return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc));
     446    return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC));
    450447}
    451448
     
    455452        return throwError(exec, TypeError);
    456453   
    457     const bool utc = true;
    458    
    459     DateInstance* thisDateObj = asDateInstance(thisValue);
    460     double milli = thisDateObj->internalNumber();
    461     if (!isfinite(milli))
     454    const bool outputIsUTC = true;
     455   
     456    DateInstance* thisDateObj = asDateInstance(thisValue);
     457   
     458    GregorianDateTime t;
     459    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    462460        return jsNontrivialString(exec, "Invalid Date");
    463    
    464     GregorianDateTime t;
    465     thisDateObj->msToGregorianDateTime(milli, utc, t);
    466461    // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds)
    467462    // 6 for formatting and one for null termination = 27.  We add one extra character to allow us to force null termination.
    468463    char buffer[28];
    469     snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast<int>(fmod(milli, 1000)));
     464    snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast<int>(fmod(thisDateObj->internalNumber(), 1000)));
    470465    buffer[sizeof(buffer) - 1] = 0;
    471466    return jsNontrivialString(exec, buffer);
     
    477472        return throwError(exec, TypeError);
    478473
    479     const bool utc = false;
    480 
    481     DateInstance* thisDateObj = asDateInstance(thisValue);
    482     double milli = thisDateObj->internalNumber();
    483     if (isnan(milli))
     474    const bool outputIsUTC = false;
     475
     476    DateInstance* thisDateObj = asDateInstance(thisValue);
     477
     478    GregorianDateTime t;
     479    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    484480        return jsNontrivialString(exec, "Invalid Date");
    485 
    486     GregorianDateTime t;
    487     thisDateObj->msToGregorianDateTime(milli, utc, t);
    488481    return jsNontrivialString(exec, formatDate(t));
    489482}
     
    494487        return throwError(exec, TypeError);
    495488
    496     const bool utc = false;
    497 
    498     DateInstance* thisDateObj = asDateInstance(thisValue);
    499     double milli = thisDateObj->internalNumber();
    500     if (isnan(milli))
     489    const bool outputIsUTC = false;
     490
     491    DateInstance* thisDateObj = asDateInstance(thisValue);
     492
     493    GregorianDateTime t;
     494    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    501495        return jsNontrivialString(exec, "Invalid Date");
    502 
    503     GregorianDateTime t;
    504     thisDateObj->msToGregorianDateTime(milli, utc, t);
    505     return jsNontrivialString(exec, formatTime(t, utc));
     496    return jsNontrivialString(exec, formatTime(t, outputIsUTC));
    506497}
    507498
     
    512503
    513504    DateInstance* thisDateObj = asDateInstance(thisValue);
    514     double milli = thisDateObj->internalNumber();
    515     if (isnan(milli))
     505    return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime, args);
     506}
     507
     508JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
     509{
     510    if (!thisValue.inherits(&DateInstance::info))
     511        return throwError(exec, TypeError);
     512
     513    DateInstance* thisDateObj = asDateInstance(thisValue);
     514    return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate, args);
     515}
     516
     517JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
     518{
     519    if (!thisValue.inherits(&DateInstance::info))
     520        return throwError(exec, TypeError);
     521
     522    DateInstance* thisDateObj = asDateInstance(thisValue);
     523    return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime, args);
     524}
     525
     526JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
     527{
     528    if (!thisValue.inherits(&DateInstance::info))
     529        return throwError(exec, TypeError);
     530
     531    return asDateInstance(thisValue)->internalValue();
     532}
     533
     534JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
     535{
     536    if (!thisValue.inherits(&DateInstance::info))
     537        return throwError(exec, TypeError);
     538
     539    const bool outputIsUTC = false;
     540
     541    DateInstance* thisDateObj = asDateInstance(thisValue);
     542
     543    GregorianDateTime t;
     544    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     545        return jsNaN(exec);
     546    return jsNumber(exec, 1900 + t.year);
     547}
     548
     549JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
     550{
     551    if (!thisValue.inherits(&DateInstance::info))
     552        return throwError(exec, TypeError);
     553
     554    const bool outputIsUTC = true;
     555
     556    DateInstance* thisDateObj = asDateInstance(thisValue);
     557
     558    GregorianDateTime t;
     559    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     560        return jsNaN(exec);
     561    return jsNumber(exec, 1900 + t.year);
     562}
     563
     564JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
     565{
     566    if (!thisValue.inherits(&DateInstance::info))
     567        return throwError(exec, TypeError);
     568
     569    const bool outputIsUTC = true;
     570
     571    DateInstance* thisDateObj = asDateInstance(thisValue);
     572
     573    GregorianDateTime t;
     574    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
    516575        return jsNontrivialString(exec, "Invalid Date");
    517 
    518     return formatLocaleDate(exec, thisDateObj, milli, LocaleDateAndTime, args);
    519 }
    520 
    521 JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
    522 {
    523     if (!thisValue.inherits(&DateInstance::info))
    524         return throwError(exec, TypeError);
    525 
    526     DateInstance* thisDateObj = asDateInstance(thisValue);
    527     double milli = thisDateObj->internalNumber();
    528     if (isnan(milli))
    529         return jsNontrivialString(exec, "Invalid Date");
    530 
    531     return formatLocaleDate(exec, thisDateObj, milli, LocaleDate, args);
    532 }
    533 
    534 JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
    535 {
    536     if (!thisValue.inherits(&DateInstance::info))
    537         return throwError(exec, TypeError);
    538 
    539     DateInstance* thisDateObj = asDateInstance(thisValue);
    540     double milli = thisDateObj->internalNumber();
    541     if (isnan(milli))
    542         return jsNontrivialString(exec, "Invalid Date");
    543 
    544     return formatLocaleDate(exec, thisDateObj, milli, LocaleTime, args);
    545 }
    546 
    547 JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    548 {
    549     if (!thisValue.inherits(&DateInstance::info))
    550         return throwError(exec, TypeError);
    551 
    552     DateInstance* thisDateObj = asDateInstance(thisValue);
    553     double milli = thisDateObj->internalNumber();
    554     if (isnan(milli))
    555         return jsNaN(exec);
    556 
    557     return jsNumber(exec, milli);
    558 }
    559 
    560 JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    561 {
    562     if (!thisValue.inherits(&DateInstance::info))
    563         return throwError(exec, TypeError);
    564 
    565     const bool utc = false;
    566 
    567     DateInstance* thisDateObj = asDateInstance(thisValue);
    568     double milli = thisDateObj->internalNumber();
    569     if (isnan(milli))
    570         return jsNaN(exec);
    571 
    572     GregorianDateTime t;
    573     thisDateObj->msToGregorianDateTime(milli, utc, t);
    574     return jsNumber(exec, 1900 + t.year);
    575 }
    576 
    577 JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    578 {
    579     if (!thisValue.inherits(&DateInstance::info))
    580         return throwError(exec, TypeError);
    581 
    582     const bool utc = true;
    583 
    584     DateInstance* thisDateObj = asDateInstance(thisValue);
    585     double milli = thisDateObj->internalNumber();
    586     if (isnan(milli))
    587         return jsNaN(exec);
    588 
    589     GregorianDateTime t;
    590     thisDateObj->msToGregorianDateTime(milli, utc, t);
    591     return jsNumber(exec, 1900 + t.year);
    592 }
    593 
    594 JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
    595 {
    596     if (!thisValue.inherits(&DateInstance::info))
    597         return throwError(exec, TypeError);
    598 
    599     const bool utc = true;
    600 
    601     DateInstance* thisDateObj = asDateInstance(thisValue);
    602     double milli = thisDateObj->internalNumber();
    603     if (isnan(milli))
    604         return jsNontrivialString(exec, "Invalid Date");
    605 
    606     GregorianDateTime t;
    607     thisDateObj->msToGregorianDateTime(milli, utc, t);
    608     return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc));
     576    return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC));
    609577}
    610578
     
    614582        return throwError(exec, TypeError);
    615583
    616     const bool utc = false;
    617 
    618     DateInstance* thisDateObj = asDateInstance(thisValue);
    619     double milli = thisDateObj->internalNumber();
    620     if (isnan(milli))
    621         return jsNaN(exec);
    622 
    623     GregorianDateTime t;
    624     thisDateObj->msToGregorianDateTime(milli, utc, t);
     584    const bool outputIsUTC = false;
     585
     586    DateInstance* thisDateObj = asDateInstance(thisValue);
     587
     588    GregorianDateTime t;
     589    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     590        return jsNaN(exec);
    625591    return jsNumber(exec, t.month);
    626592}
     
    631597        return throwError(exec, TypeError);
    632598
    633     const bool utc = true;
    634 
    635     DateInstance* thisDateObj = asDateInstance(thisValue);
    636     double milli = thisDateObj->internalNumber();
    637     if (isnan(milli))
    638         return jsNaN(exec);
    639 
    640     GregorianDateTime t;
    641     thisDateObj->msToGregorianDateTime(milli, utc, t);
     599    const bool outputIsUTC = true;
     600
     601    DateInstance* thisDateObj = asDateInstance(thisValue);
     602
     603    GregorianDateTime t;
     604    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     605        return jsNaN(exec);
    642606    return jsNumber(exec, t.month);
    643607}
     
    648612        return throwError(exec, TypeError);
    649613
    650     const bool utc = false;
    651 
    652     DateInstance* thisDateObj = asDateInstance(thisValue);
    653     double milli = thisDateObj->internalNumber();
    654     if (isnan(milli))
    655         return jsNaN(exec);
    656 
    657     GregorianDateTime t;
    658     thisDateObj->msToGregorianDateTime(milli, utc, t);
     614    const bool outputIsUTC = false;
     615
     616    DateInstance* thisDateObj = asDateInstance(thisValue);
     617
     618    GregorianDateTime t;
     619    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     620        return jsNaN(exec);
    659621    return jsNumber(exec, t.monthDay);
    660622}
     
    665627        return throwError(exec, TypeError);
    666628
    667     const bool utc = true;
    668 
    669     DateInstance* thisDateObj = asDateInstance(thisValue);
    670     double milli = thisDateObj->internalNumber();
    671     if (isnan(milli))
    672         return jsNaN(exec);
    673 
    674     GregorianDateTime t;
    675     thisDateObj->msToGregorianDateTime(milli, utc, t);
     629    const bool outputIsUTC = true;
     630
     631    DateInstance* thisDateObj = asDateInstance(thisValue);
     632
     633    GregorianDateTime t;
     634    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     635        return jsNaN(exec);
    676636    return jsNumber(exec, t.monthDay);
    677637}
     
    682642        return throwError(exec, TypeError);
    683643
    684     const bool utc = false;
    685 
    686     DateInstance* thisDateObj = asDateInstance(thisValue);
    687     double milli = thisDateObj->internalNumber();
    688     if (isnan(milli))
    689         return jsNaN(exec);
    690 
    691     GregorianDateTime t;
    692     thisDateObj->msToGregorianDateTime(milli, utc, t);
     644    const bool outputIsUTC = false;
     645
     646    DateInstance* thisDateObj = asDateInstance(thisValue);
     647
     648    GregorianDateTime t;
     649    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     650        return jsNaN(exec);
    693651    return jsNumber(exec, t.weekDay);
    694652}
     
    699657        return throwError(exec, TypeError);
    700658
    701     const bool utc = true;
    702 
    703     DateInstance* thisDateObj = asDateInstance(thisValue);
    704     double milli = thisDateObj->internalNumber();
    705     if (isnan(milli))
    706         return jsNaN(exec);
    707 
    708     GregorianDateTime t;
    709     thisDateObj->msToGregorianDateTime(milli, utc, t);
     659    const bool outputIsUTC = true;
     660
     661    DateInstance* thisDateObj = asDateInstance(thisValue);
     662
     663    GregorianDateTime t;
     664    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     665        return jsNaN(exec);
    710666    return jsNumber(exec, t.weekDay);
    711667}
     
    716672        return throwError(exec, TypeError);
    717673
    718     const bool utc = false;
    719 
    720     DateInstance* thisDateObj = asDateInstance(thisValue);
    721     double milli = thisDateObj->internalNumber();
    722     if (isnan(milli))
    723         return jsNaN(exec);
    724 
    725     GregorianDateTime t;
    726     thisDateObj->msToGregorianDateTime(milli, utc, t);
     674    const bool outputIsUTC = false;
     675
     676    DateInstance* thisDateObj = asDateInstance(thisValue);
     677
     678    GregorianDateTime t;
     679    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     680        return jsNaN(exec);
    727681    return jsNumber(exec, t.hour);
    728682}
     
    733687        return throwError(exec, TypeError);
    734688
    735     const bool utc = true;
    736 
    737     DateInstance* thisDateObj = asDateInstance(thisValue);
    738     double milli = thisDateObj->internalNumber();
    739     if (isnan(milli))
    740         return jsNaN(exec);
    741 
    742     GregorianDateTime t;
    743     thisDateObj->msToGregorianDateTime(milli, utc, t);
     689    const bool outputIsUTC = true;
     690
     691    DateInstance* thisDateObj = asDateInstance(thisValue);
     692
     693    GregorianDateTime t;
     694    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     695        return jsNaN(exec);
    744696    return jsNumber(exec, t.hour);
    745697}
     
    750702        return throwError(exec, TypeError);
    751703
    752     const bool utc = false;
    753 
    754     DateInstance* thisDateObj = asDateInstance(thisValue);
    755     double milli = thisDateObj->internalNumber();
    756     if (isnan(milli))
    757         return jsNaN(exec);
    758 
    759     GregorianDateTime t;
    760     thisDateObj->msToGregorianDateTime(milli, utc, t);
     704    const bool outputIsUTC = false;
     705
     706    DateInstance* thisDateObj = asDateInstance(thisValue);
     707
     708    GregorianDateTime t;
     709    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     710        return jsNaN(exec);
    761711    return jsNumber(exec, t.minute);
    762712}
     
    767717        return throwError(exec, TypeError);
    768718
    769     const bool utc = true;
    770 
    771     DateInstance* thisDateObj = asDateInstance(thisValue);
    772     double milli = thisDateObj->internalNumber();
    773     if (isnan(milli))
    774         return jsNaN(exec);
    775 
    776     GregorianDateTime t;
    777     thisDateObj->msToGregorianDateTime(milli, utc, t);
     719    const bool outputIsUTC = true;
     720
     721    DateInstance* thisDateObj = asDateInstance(thisValue);
     722
     723    GregorianDateTime t;
     724    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     725        return jsNaN(exec);
    778726    return jsNumber(exec, t.minute);
    779727}
     
    784732        return throwError(exec, TypeError);
    785733
    786     const bool utc = false;
    787 
    788     DateInstance* thisDateObj = asDateInstance(thisValue);
    789     double milli = thisDateObj->internalNumber();
    790     if (isnan(milli))
    791         return jsNaN(exec);
    792 
    793     GregorianDateTime t;
    794     thisDateObj->msToGregorianDateTime(milli, utc, t);
     734    const bool outputIsUTC = false;
     735
     736    DateInstance* thisDateObj = asDateInstance(thisValue);
     737
     738    GregorianDateTime t;
     739    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     740        return jsNaN(exec);
    795741    return jsNumber(exec, t.second);
    796742}
     
    801747        return throwError(exec, TypeError);
    802748
    803     const bool utc = true;
    804 
    805     DateInstance* thisDateObj = asDateInstance(thisValue);
    806     double milli = thisDateObj->internalNumber();
    807     if (isnan(milli))
    808         return jsNaN(exec);
    809 
    810     GregorianDateTime t;
    811     thisDateObj->msToGregorianDateTime(milli, utc, t);
     749    const bool outputIsUTC = true;
     750
     751    DateInstance* thisDateObj = asDateInstance(thisValue);
     752
     753    GregorianDateTime t;
     754    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     755        return jsNaN(exec);
    812756    return jsNumber(exec, t.second);
    813757}
     
    848792        return throwError(exec, TypeError);
    849793
    850     const bool utc = false;
    851 
    852     DateInstance* thisDateObj = asDateInstance(thisValue);
    853     double milli = thisDateObj->internalNumber();
    854     if (isnan(milli))
    855         return jsNaN(exec);
    856 
    857     GregorianDateTime t;
    858     thisDateObj->msToGregorianDateTime(milli, utc, t);
     794    const bool outputIsUTC = false;
     795
     796    DateInstance* thisDateObj = asDateInstance(thisValue);
     797
     798    GregorianDateTime t;
     799    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     800        return jsNaN(exec);
    859801    return jsNumber(exec, -gmtoffset(t) / minutesPerHour);
    860802}
     
    891833
    892834    GregorianDateTime t;
    893     thisDateObj->msToGregorianDateTime(milli, inputIsUTC, t);
     835    thisDateObj->getGregorianDateTime(inputIsUTC, t);
    894836
    895837    if (!fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t)) {
     
    923865        // Based on ECMA 262 15.9.5.40 - .41 (set[UTC]FullYear)
    924866        // the time must be reset to +0 if it is NaN.
    925         thisDateObj->msToGregorianDateTime(0, true, t);
     867        WTF::msToGregorianDateTime(0, true, t);
    926868    else {
    927869        double secs = floor(milli / msPerSecond);
    928870        ms = milli - secs * msPerSecond;
    929         thisDateObj->msToGregorianDateTime(milli, inputIsUTC, t);
     871        thisDateObj->getGregorianDateTime(inputIsUTC, t);
    930872    }
    931873   
     
    1030972        return throwError(exec, TypeError);
    1031973
    1032     const bool utc = false;
     974    const bool outputIsUTC = false;
    1033975
    1034976    DateInstance* thisDateObj = asDateInstance(thisValue);     
     
    1046988        // Based on ECMA 262 B.2.5 (setYear)
    1047989        // the time must be reset to +0 if it is NaN.
    1048         thisDateObj->msToGregorianDateTime(0, true, t);
     990        WTF::msToGregorianDateTime(0, true, t);
    1049991    else {   
    1050992        double secs = floor(milli / msPerSecond);
    1051993        ms = milli - secs * msPerSecond;
    1052         thisDateObj->msToGregorianDateTime(milli, utc, t);
     994        thisDateObj->getGregorianDateTime(outputIsUTC, t);
    1053995    }
    1054996   
     
    10621004           
    10631005    t.year = (year > 99 || year < 0) ? year - 1900 : year;
    1064     JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, utc));
     1006    JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, outputIsUTC));
    10651007    thisDateObj->setInternalValue(result);
    10661008    return result;
     
    10721014        return throwError(exec, TypeError);
    10731015
    1074     const bool utc = false;
    1075 
    1076     DateInstance* thisDateObj = asDateInstance(thisValue);
    1077     double milli = thisDateObj->internalNumber();
    1078     if (isnan(milli))
    1079         return jsNaN(exec);
    1080 
    1081     GregorianDateTime t;
    1082     thisDateObj->msToGregorianDateTime(milli, utc, t);
     1016    const bool outputIsUTC = false;
     1017
     1018    DateInstance* thisDateObj = asDateInstance(thisValue);
     1019
     1020    GregorianDateTime t;
     1021    if (!thisDateObj->getGregorianDateTime(outputIsUTC, t))
     1022        return jsNaN(exec);
    10831023
    10841024    // NOTE: IE returns the full year even in getYear.
Note: See TracChangeset for help on using the changeset viewer.