Changeset 16855 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 6, 2006, 11:16:38 AM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r16808 r16855 1 2006-10-06 Kevin McCullough <[email protected]> 2 3 Reviewed by Brady. 4 5 DST and TimeZones were wrong in some cases, specifically on some of the dates where DST changes. 6 7 * kjs/DateMath.cpp: 8 (KJS::equivalentYearForDST): 9 (KJS::getUTCOffset): 10 (KJS::getDSTOffsetSimple): 11 (KJS::getDSTOffset): 12 (KJS::dateToMseconds): 13 (KJS::msToTM): 14 * kjs/DateMath.h: 15 * kjs/date_object.cpp: 16 (KJS::gmtoffset): 17 1 18 2006-10-05 Darin Adler <[email protected]> 2 19 -
trunk/JavaScriptCore/kjs/DateMath.cpp
r16798 r16855 304 304 305 305 day = (int) daysFrom1970ToYear(year) + 4; 306 day = day %7;306 day %= 7; 307 307 308 308 if (day < 0) … … 330 330 ltime.tm_isdst = 0; 331 331 332 / * get the difference between this time zone and GMT */332 // get the difference between this time zone and GMT 333 333 ltime.tm_mday = 2; 334 334 ltime.tm_year = 70; … … 356 356 if(localTimeSeconds > maxUnixTime) 357 357 localTimeSeconds = maxUnixTime; 358 else if(localTimeSeconds < 0) /*go ahead a day to make localtime work (does not work with 0) */ 359 localTimeSeconds = secondsPerDay; 360 358 else if(localTimeSeconds < 0) // Go ahead a day to make localtime work (does not work with 0) 359 localTimeSeconds += secondsPerDay; 360 361 struct tm prtm; 361 362 double offsetTime = (localTimeSeconds * usecPerMsec) + getUTCOffset() ; 362 363 363 struct tm prtm;364 prtm.tm_hour = msToHours(offsetTime); 364 365 prtm.tm_min = msToMinutes(offsetTime); 365 prtm.tm_hour = msToHours(offsetTime);366 366 367 367 // FIXME: time_t has a potential problem in 2038 … … 399 399 } 400 400 401 /* put our ms in an LL, and map it to usec for prtime */402 401 return getDSTOffsetSimple(ms / usecPerMsec); 403 }404 405 static inline double localTimeToUTC(double ms)406 {407 ms -= getUTCOffset();408 ms -= getDSTOffset(ms);409 return ms;410 }411 412 static inline double UTCToLocalTime(double ms)413 {414 ms += getUTCOffset();415 ms += getDSTOffset(ms);416 return ms;417 402 } 418 403 … … 423 408 double result = (day * msPerDay) + msec_time; 424 409 425 if(!inputIsUTC) 426 result = localTimeToUTC(result); 410 if(!inputIsUTC) { // convert to UTC 411 result -= getUTCOffset(); 412 result -= getDSTOffset(result); 413 } 427 414 428 415 return result; … … 431 418 void msToTM(double ms, bool outputIsUTC, struct tm& tm) 432 419 { 433 //input is UTC 434 if(!outputIsUTC) 435 ms = UTCToLocalTime(ms); 420 // input is UTC 421 double dstOff = 0.0; 422 423 if(!outputIsUTC) { // convert to local time 424 dstOff = getDSTOffset(ms); 425 ms += dstOff + getUTCOffset(); 426 } 436 427 437 428 tm.tm_sec = msToSeconds(ms); … … 443 434 tm.tm_mon = msToMonth(ms); 444 435 tm.tm_year = msToYear(ms) - 1900; 445 tm.tm_isdst = isDST(ms);446 447 // everyone elseseems to have these fields436 tm.tm_isdst = dstOff != 0.0; 437 438 // All other OS' seems to have these fields 448 439 #if !PLATFORM(WIN_OS) 449 440 struct tm xtm; … … 456 447 } 457 448 458 bool isDST(const double& ms) 459 { 460 return getDSTOffset(ms) != 0; 461 } 462 463 } //namespace KJS 464 449 } // namespace KJS 450 -
trunk/JavaScriptCore/kjs/DateMath.h
r16780 r16855 62 62 void msToTM(double, bool outputIsUTC, struct tm& ); 63 63 double dateToMseconds(tm*, double, bool inputIsUTC); 64 bool isDST(const double&);65 64 double getUTCOffset(); 66 65 -
trunk/JavaScriptCore/kjs/date_object.cpp
r16798 r16855 70 70 #if PLATFORM(WIN_OS) 71 71 // Time is supposed to be in the current timezone. 72 static int utcOffset = static_cast<int>(getUTCOffset()/1000.0); 73 return utcOffset; 72 return -(_timezone / 60 - (t.tm_isdst != 0 ? 60 : 0 )) * 60; 74 73 #else 75 74 return t.tm_gmtoff;
Note:
See TracChangeset
for help on using the changeset viewer.