Changeset 51986 in webkit for trunk/JavaScriptCore/wtf/DateMath.cpp
- Timestamp:
- Dec 11, 2009, 7:39:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/DateMath.cpp
r51955 r51986 121 121 122 122 static const double maxUnixTime = 2145859200.0; // 12/31/2037 123 // ECMAScript asks not to support for a date of which total 124 // millisecond value is larger than the following value. 125 // See 15.9.1.14 of ECMA-262 5th edition. 126 static const double maxECMAScriptTime = 8.64E15; 123 127 124 128 // Day of year for the first day of each month, where index 0 is January, and day 0 is January 1. … … 307 311 } 308 312 309 static int dateToDayInYear(int year, int month, int day)313 static double dateToDaysFrom1970(int year, int month, int day) 310 314 { 311 315 year += month / 12; … … 317 321 } 318 322 319 int yearday = static_cast<int>(floor(daysFrom1970ToYear(year))); 323 double yearday = floor(daysFrom1970ToYear(year)); 324 ASSERT((year >= 1970 && yearday >= 0) || (year < 1970 && yearday < 0)); 320 325 int monthday = monthToDayInYear(month, isLeapYear(year)); 321 326 … … 453 458 int dayInMonth = dayInMonthFromDayInYear(dayInYearLocal, leapYear); 454 459 int month = monthFromDayInYear(dayInYearLocal, leapYear); 455 int day = dateToDayInYear(equivalentYear, month, dayInMonth);460 double day = dateToDaysFrom1970(equivalentYear, month, dayInMonth); 456 461 ms = (day * msPerDay) + msToMilliseconds(ms); 457 462 } … … 842 847 if (!isfinite(t)) 843 848 return NaN; 844 if (fabs(t) > 8.64E15)849 if (fabs(t) > maxECMAScriptTime) 845 850 return NaN; 846 851 return trunc(t); … … 928 933 double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC) 929 934 { 930 int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);935 double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay); 931 936 double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds); 932 937 double result = (day * WTF::msPerDay) + ms;
Note:
See TracChangeset
for help on using the changeset viewer.