Changeset 17520 in webkit for trunk/JavaScriptCore/kjs/DateMath.cpp
- Timestamp:
- Nov 1, 2006, 12:34:23 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/DateMath.cpp
r17333 r17520 66 66 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} 67 67 }; 68 69 70 /*71 * Years and leap years on which Jan 1 is a Sunday, Monday, etc.72 *73 * yearStartingWith[0][i] is an example non-leap year where74 * Jan 1 appears on Sunday (i == 0), Monday (i == 1), etc.75 *76 * yearStartingWith[1][i] is an example leap year where77 * Jan 1 appears on Sunday (i == 0), Monday (i == 1), etc.78 */79 static int yearStartingWith[2][7] = {80 {1978, 1973, 1974, 1975, 1981, 1971, 1977},81 {1984, 1996, 1980, 1992, 1976, 1988, 1972}82 };83 84 68 85 69 static inline int daysInYear(int year) … … 299 283 int equivalentYearForDST(int year) 300 284 { 301 int day; 302 303 day = (int) daysFrom1970ToYear(year) + 4; 304 day %= 7; 305 306 if (day < 0) 307 day += 7; 308 309 return yearStartingWith[isLeapYear(year)][day]; 285 int difference = 2000 - year; // Arbitrary year around which most dates equivalence is correct 286 int quotient = difference / 28; // Integer division, no remainder. 287 int product = quotient * 28; 288 return year + product; 310 289 } 311 290 … … 346 325 localTimeSeconds += secondsPerDay; 347 326 327 //input is UTC so we have to shift back to local time to determine DST thus the + getUTCOffset() 348 328 double offsetTime = (localTimeSeconds * msPerSecond) + getUTCOffset() ; 349 329 … … 374 354 static double getDSTOffset(double ms) 375 355 { 376 /* 377 * If earlier than 1970 or after 2038, potentially beyond the ken of 378 * many OSes, map it to an equivalent year before asking. 379 */ 380 if (ms < 0.0 || ms > 2145916800000.0) { 356 // On mac the call to localtime (see getDSTOffsetSimple) will return historically accurate 357 // DST information (e.g. New Zealand did not have DST from 1946 to 1974) however the JavaScript 358 // standard explicitly dictates that historical information should not be considered when 359 // determining DST. For this reason we shift years that localtime can handle but would 360 // return historically accurate information. 361 362 //if before 2000 or after 2038 363 if (ms < 946684800000.0 || ms > 2145916800000.0) { 381 364 int year; 382 365 int day;
Note:
See TracChangeset
for help on using the changeset viewer.