Changeset 31057 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Mar 14, 2008, 7:59:38 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Get rid of a localime() call on platforms that have better alternatives.

  • kjs/DateMath.h: Added getLocalTime();
  • kjs/DateMath.cpp: (KJS::getLocalTime): (KJS::getDSTOffsetSimple): Implementation moved from getDSTOffsetSimple().
  • kjs/date_object.cpp: (KJS::DateObjectImp::callAsFunction): Switched to getLocalTime().
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r31056 r31057  
     12008-03-14  Alexey Proskuryakov  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Get rid of a localime() call on platforms that have better alternatives.
     6
     7        * kjs/DateMath.h: Added getLocalTime();
     8
     9        * kjs/DateMath.cpp:
     10        (KJS::getLocalTime):
     11        (KJS::getDSTOffsetSimple):
     12        Implementation moved from getDSTOffsetSimple().
     13
     14        * kjs/date_object.cpp:
     15        (KJS::DateObjectImp::callAsFunction): Switched to getLocalTime().
     16
    1172008-03-14  David D. Kilzer  <[email protected]>
    218
  • trunk/JavaScriptCore/kjs/DateMath.cpp

    r29663 r31057  
    293293}
    294294
     295void getLocalTime(const time_t* localTime, struct tm* localTM)
     296{
     297#if PLATFORM(QT)
     298#if USE(MULTIPLE_THREADS)
     299#error Mulitple threads are currently not supported in the Qt/mingw build
     300#endif
     301    *localTM = *localtime(localTime);
     302#elif PLATFORM(WIN_OS)
     303    #if COMPILER(MSVC7)
     304    *localTM = *localtime(localTime);
     305    #else
     306    localtime_s(localTM, localTime);
     307    #endif
     308#else
     309    localtime_r(localTime, localTM);
     310#endif
     311}
     312
    295313// There is a hard limit at 2038 that we currently do not have a workaround
    296314// for (rdar://problem/5052975).
     
    416434
    417435    tm localTM;
    418 #if PLATFORM(QT)
    419     // ### this is not threadsafe but we don't use multiple threads anyway
    420     // in the Qt build
    421 #if USE(MULTIPLE_THREADS)
    422 #error Mulitple threads are currently not supported in the Qt/mingw build
    423 #endif
    424     localTM = *localtime(&localTime);
    425 #elif PLATFORM(WIN_OS)
    426     #if COMPILER(MSVC7)
    427     localTM = *localtime(&localTime);
    428     #else
    429     localtime_s(&localTM, &localTime);
    430     #endif
    431 #else
    432     localtime_r(&localTime, &localTM);
    433 #endif
     436    getLocalTime(&localTime, &localTM);
    434437
    435438    double diff = ((localTM.tm_hour - offsetHour) * secondsPerHour) + ((localTM.tm_min - offsetMinute) * 60);
  • trunk/JavaScriptCore/kjs/DateMath.h

    r29663 r31057  
    5555int equivalentYearForDST(int year);
    5656double getCurrentUTCTime();
     57void getLocalTime(const time_t*, tm*);
     58
    5759
    5860const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r30625 r31057  
    518518JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/)
    519519{
    520     time_t t = time(0);
    521     GregorianDateTime ts(*localtime(&t));
     520    time_t localTime = time(0);
     521    tm localTM;
     522    getLocalTime(&localTime, &localTM);
     523    GregorianDateTime ts(localTM);
    522524    return jsString(formatDate(ts) + " " + formatTime(ts, false));
    523525}
Note: See TracChangeset for help on using the changeset viewer.