Ignore:
Timestamp:
Jan 6, 2006, 2:43:44 PM (19 years ago)
Author:
hyatt
Message:

Land all the changes to make JSCore build again on windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r11640 r11918  
    6060#define isfinite(x) _finite(x)
    6161#define strncasecmp(x, y, z) strnicmp(x, y, z)
    62 #endif
     62#define snprintf _snprintf
     63#endif
     64
     65inline int gmtoffset(const tm& t)
     66{
     67#if WIN32
     68    // FIXME: This might not be completely correct if the time is not the current timezone.
     69    return -(timezone / 60 - (t.tm_isdst > 0 ? 60 : 0 )) * 60;
     70#else
     71    return t.tm_gmtoff;
     72#endif
     73}
    6374
    6475namespace KJS {
     
    219230{
    220231    char buffer[100];
    221     if (t.tm_gmtoff == 0) {
     232    if (gmtoffset(t) == 0) {
    222233        snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.tm_hour, t.tm_min, t.tm_sec);
    223234    } else {
    224         int offset = abs(t.tm_gmtoff);
     235        int offset = abs(gmtoffset(t));
    225236        snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d",
    226237            t.tm_hour, t.tm_min, t.tm_sec,
    227             t.tm_gmtoff < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
     238            gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
    228239    }
    229240    return UString(buffer);
     
    548559  double ms = milli - tv * msPerSecond;
    549560
    550   tm t;
    551   utc ? gmtime_r(&tv, &t) : localtime_r(&tv, &t);
     561  tm t = *(utc ? gmtime(&tv) : localtime(&tv));
    552562  // We had an out of range year. Restore the year (plus/minus offset
    553563  // found by calculating tm_year) and fix the week day calculation.
     
    770780{
    771781    time_t t = time(0);
    772     tm ts;
    773     localtime_r(&t, &ts);
     782    tm ts = *localtime(&t);
    774783    return jsString(formatDate(ts) + " " + formatTime(ts));
    775784}
     
    900909    if (!utc) {
    901910        time_t tval = mktime(t) + (time_t)((ms + yearOffset) / 1000); 
    902         struct tm t3; 
    903         localtime_r(&tval, &t3); 
     911        tm t3 = *localtime(&tval); 
    904912        t->tm_isdst = t3.tm_isdst; 
    905913    }
Note: See TracChangeset for help on using the changeset viewer.