Changeset 11918 in webkit for trunk/JavaScriptCore/kjs/date_object.cpp
- Timestamp:
- Jan 6, 2006, 2:43:44 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/date_object.cpp
r11640 r11918 60 60 #define isfinite(x) _finite(x) 61 61 #define strncasecmp(x, y, z) strnicmp(x, y, z) 62 #endif 62 #define snprintf _snprintf 63 #endif 64 65 inline 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 } 63 74 64 75 namespace KJS { … … 219 230 { 220 231 char buffer[100]; 221 if ( t.tm_gmtoff== 0) {232 if (gmtoffset(t) == 0) { 222 233 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.tm_hour, t.tm_min, t.tm_sec); 223 234 } else { 224 int offset = abs( t.tm_gmtoff);235 int offset = abs(gmtoffset(t)); 225 236 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d", 226 237 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); 228 239 } 229 240 return UString(buffer); … … 548 559 double ms = milli - tv * msPerSecond; 549 560 550 tm t; 551 utc ? gmtime_r(&tv, &t) : localtime_r(&tv, &t); 561 tm t = *(utc ? gmtime(&tv) : localtime(&tv)); 552 562 // We had an out of range year. Restore the year (plus/minus offset 553 563 // found by calculating tm_year) and fix the week day calculation. … … 770 780 { 771 781 time_t t = time(0); 772 tm ts; 773 localtime_r(&t, &ts); 782 tm ts = *localtime(&t); 774 783 return jsString(formatDate(ts) + " " + formatTime(ts)); 775 784 } … … 900 909 if (!utc) { 901 910 time_t tval = mktime(t) + (time_t)((ms + yearOffset) / 1000); 902 struct tm t3; 903 localtime_r(&tval, &t3); 911 tm t3 = *localtime(&tval); 904 912 t->tm_isdst = t3.tm_isdst; 905 913 }
Note:
See TracChangeset
for help on using the changeset viewer.