Ignore:
Timestamp:
Nov 8, 2009, 6:33:04 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Hopefully, the last build fix.

Reviewed by NOBODY (chromium build fix).

Create better separation in DateMath about the JSC
and non-JSC portions. Also, only expose the non-JSC
version in the exports.

(WTF::parseDateFromNullTerminatedCharacters):
(JSC::getUTCOffset):
(JSC::gregorianDateTimeToMS):
(JSC::msToGregorianDateTime):
(JSC::parseDateFromNullTerminatedCharacters):

  • wtf/DateMath.h:

(JSC::gmtoffset):

JavaScriptGlue: Added the use jsc define for files that use
this config file and DateMath.h. This should
be able to go away when DateMath is properly
split into wtf and jsc portions which is this bug:
https://bugs.webkit.org/show_bug.cgi?id=31246

Reviewed by NOBODY (chromium build fix).

  • config.h:

WebCore: * platform/network/HTTPParsers.cpp:
(WebCore::parseDate): Changed this to not
use a date parser that needs ExecState passed.

Reviewed by NOBODY (chromium build fix).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/DateMath.cpp

    r50628 r50633  
    8383using namespace WTF;
    8484
    85 namespace JSC {
     85namespace WTF {
    8686
    8787/* Constants */
     
    380380}
    381381
    382 #if USE(JSC)
    383 /*
    384  * Get the difference in milliseconds between this time zone and UTC (GMT)
    385  * NOT including DST.
    386  */
    387 double getUTCOffset(ExecState* exec)
    388 {
    389     double utcOffset = exec->globalData().cachedUTCOffset;
    390     if (!isnan(utcOffset))
    391         return utcOffset;
    392     exec->globalData().cachedUTCOffset = calculateUTCOffset();
    393     return exec->globalData().cachedUTCOffset;
    394 }
    395 #endif
    396 
    397382/*
    398383 * Get the DST offset for the time passed in.  Takes
     
    450435}
    451436
    452 double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
    453 {
    454     int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);
    455     double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
    456     double result = (day * msPerDay) + ms;
    457 
    458     if (!inputIsUTC) { // convert to UTC
    459         double utcOffset = getUTCOffset(exec);
    460         result -= utcOffset;
    461         result -= getDSTOffset(result, utcOffset);
    462     }
    463 
    464     return result;
    465 }
    466 
    467 // input is UTC
    468 void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, GregorianDateTime& tm)
    469 {
    470     double dstOff = 0.0;
    471     double utcOff = 0.0;
    472     if (!outputIsUTC) {
    473         utcOff = getUTCOffset(exec);
    474         dstOff = getDSTOffset(ms, utcOff);
    475         ms += dstOff + utcOff;
    476     }
    477 
    478     const int year = msToYear(ms);
    479     tm.second   =  msToSeconds(ms);
    480     tm.minute   =  msToMinutes(ms);
    481     tm.hour     =  msToHours(ms);
    482     tm.weekDay  =  msToWeekDay(ms);
    483     tm.yearDay  =  dayInYear(ms, year);
    484     tm.monthDay =  dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year));
    485     tm.month    =  monthFromDayInYear(tm.yearDay, isLeapYear(year));
    486     tm.year     =  year - 1900;
    487     tm.isDST    =  dstOff != 0.0;
    488     tm.utcOffset = static_cast<long>((dstOff + utcOff) / msPerSecond);
    489     tm.timeZone = NULL;
    490 }
    491 
    492437void initializeDates()
    493438{
     
    579524
    580525// Odd case where 'exec' is allowed to be 0, to accomodate a caller in WebCore.
    581 double parseDateFromNullTerminatedCharacters(const char* dateString, ExecState* exec)
    582 {
     526double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveTZ, int& offset)
     527{
     528    haveTZ = false;
     529    offset = 0;
     530
    583531    // This parses a date in the form:
    584532    //     Tuesday, 09-Nov-99 23:12:40 GMT
     
    780728        }
    781729    }
    782 
    783     bool haveTZ = false;
    784     int offset = 0;
    785730
    786731    // Don't fail if the time zone is missing.
     
    847792    }
    848793   
    849     double ms = ymdhmsToSeconds(year, month + 1, day, hour, minute, second) * msPerSecond;
     794    return ymdhmsToSeconds(year, month + 1, day, hour, minute, second) * msPerSecond;
     795}
     796
     797double parseDateFromNullTerminatedCharacters(const char* dateString)
     798{
     799    bool haveTZ;
     800    int offset;
     801    double ms = parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
    850802    // fall back to local timezone
    851803    if (!haveTZ) {
    852         if (exec) {
    853             double utcOffset = getUTCOffset(exec);
    854             double dstOffset = getDSTOffset(ms, utcOffset);
    855             offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
    856         } else {
    857             double utcOffset = calculateUTCOffset();
    858             double dstOffset = getDSTOffset(ms, utcOffset);
    859             offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
    860         }
    861     }
    862 
     804        double utcOffset = calculateUTCOffset();
     805        double dstOffset = getDSTOffset(ms, utcOffset);
     806        offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
     807    }
    863808    return ms - (offset * msPerMinute);
    864809}
     
    872817    return trunc(t);
    873818}
    874 
     819} // namespace WTF
     820
     821#if USE(JSC)
     822namespace JSC {
     823/*
     824 * Get the difference in milliseconds between this time zone and UTC (GMT)
     825 * NOT including DST.
     826 */
     827double getUTCOffset(ExecState* exec)
     828{
     829    double utcOffset = exec->globalData().cachedUTCOffset;
     830    if (!isnan(utcOffset))
     831        return utcOffset;
     832    exec->globalData().cachedUTCOffset = calculateUTCOffset();
     833    return exec->globalData().cachedUTCOffset;
     834}
     835
     836double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
     837{
     838    int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);
     839    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
     840    double result = (day * msPerDay) + ms;
     841
     842    if (!inputIsUTC) { // convert to UTC
     843        double utcOffset = getUTCOffset(exec);
     844        result -= utcOffset;
     845        result -= getDSTOffset(result, utcOffset);
     846    }
     847
     848    return result;
     849}
     850
     851// input is UTC
     852void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, GregorianDateTime& tm)
     853{
     854    double dstOff = 0.0;
     855    double utcOff = 0.0;
     856    if (!outputIsUTC) {
     857        utcOff = getUTCOffset(exec);
     858        dstOff = getDSTOffset(ms, utcOff);
     859        ms += dstOff + utcOff;
     860    }
     861
     862    const int year = msToYear(ms);
     863    tm.second   =  msToSeconds(ms);
     864    tm.minute   =  msToMinutes(ms);
     865    tm.hour     =  msToHours(ms);
     866    tm.weekDay  =  msToWeekDay(ms);
     867    tm.yearDay  =  dayInYear(ms, year);
     868    tm.monthDay =  dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year));
     869    tm.month    =  monthFromDayInYear(tm.yearDay, isLeapYear(year));
     870    tm.year     =  year - 1900;
     871    tm.isDST    =  dstOff != 0.0;
     872    tm.utcOffset = static_cast<long>((dstOff + utcOff) / msPerSecond);
     873    tm.timeZone = NULL;
     874}
     875
     876double parseDateFromNullTerminatedCharacters(const char* dateString, ExecState* exec)
     877{
     878    ASSERT(exec);
     879    bool haveTZ;
     880    int offset;
     881    double ms = WTF::parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
     882    // fall back to local timezone
     883    if (!haveTZ) {
     884        double utcOffset = getUTCOffset(exec);
     885        double dstOffset = getDSTOffset(ms, utcOffset);
     886        offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
     887    }
     888    return ms - (offset * msPerMinute);
     889}
    875890
    876891} // namespace JSC
     892#endif // USE(JSC)
Note: See TracChangeset for help on using the changeset viewer.