Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: src/date-delay.js

Issue 12824: Change Windows daylight saving time calculations to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 105
106 // ECMA 262 - 15.9.1.5 106 // ECMA 262 - 15.9.1.5
107 function DateFromTime(time) { 107 function DateFromTime(time) {
108 return FromJulianDay(Day(time) + kDayZeroInJulianDay).date; 108 return FromJulianDay(Day(time) + kDayZeroInJulianDay).date;
109 } 109 }
110 110
111 111
112 // ECMA 262 - 15.9.1.9 112 // ECMA 262 - 15.9.1.9
113 function EquivalentYear(year) { 113 function EquivalentYear(year) {
114 // Returns an equivalent year in the range [1956-2000] matching 114 // Returns an equivalent year in the range [2008-2035] matching
115 // - leap year. 115 // - leap year.
116 // - week day of first day. 116 // - week day of first day.
117 var time = TimeFromYear(year); 117 var time = TimeFromYear(year);
118 return (InLeapYear(time) == 0 ? 1967 : 1956) + (WeekDay(time) * 12) % 28; 118 var recent_year = (InLeapYear(time) == 0 ? 1967 : 1956) +
119 (WeekDay(time) * 12) % 28;
120 // Find the year in the range 2008..2037 that is equivalent mod 28.
121 // Add 3*28 to give a positive argument to the modulus operator.
122 return 2008 + (recent_year + 3*28 - 2008) % 28;
119 } 123 }
120 124
121 125
122 function EquivalentTime(t) { 126 function EquivalentTime(t) {
123 // The issue here is that some library calls don't work right for dates 127 // The issue here is that some library calls don't work right for dates
124 // that cannot be represented using a signed 32 bit integer (measured in 128 // that cannot be represented using a non-negative signed 32 bit integer
125 // whole seconds based on the 1970 epoch). 129 // (measured in whole seconds based on the 1970 epoch).
126 // We solve this by mapping the time to a year with same leap-year-ness 130 // We solve this by mapping the time to a year with same leap-year-ness
127 // and same starting day for the year. 131 // and same starting day for the year. The ECMAscript specification says
128 // As an optimization we avoid finding an equivalent year in the common 132 // we must do this, but for compatability with other browsers, we use
129 // case. We are measuring in ms here so the 32 bit signed integer range 133 // the actual year if it is in the range 1970..2037
130 // is +-(1<<30)*1000 ie approximately +-2.1e20. 134 if (t >= 0 && t <= 2.1e12) return t;
131 if (t >= -2.1e12 && t <= 2.1e12) return t;
132 var day = MakeDay(EquivalentYear(YearFromTime(t)), MonthFromTime(t), DateFromT ime(t)); 135 var day = MakeDay(EquivalentYear(YearFromTime(t)), MonthFromTime(t), DateFromT ime(t));
133 return TimeClip(MakeDate(day, TimeWithinDay(t))); 136 return TimeClip(MakeDate(day, TimeWithinDay(t)));
134 } 137 }
135 138
136 var daylight_cache_time = $NaN; 139 var daylight_cache_time = $NaN;
137 var daylight_cache_offset; 140 var daylight_cache_offset;
138 141
139 function DaylightSavingsOffset(t) { 142 function DaylightSavingsOffset(t) {
140 if (t == daylight_cache_time) { 143 if (t == daylight_cache_time) {
141 return daylight_cache_offset; 144 return daylight_cache_offset;
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 "setFullYear", DateSetFullYear, 1031 "setFullYear", DateSetFullYear,
1029 "setUTCFullYear", DateSetUTCFullYear, 1032 "setUTCFullYear", DateSetUTCFullYear,
1030 "toGMTString", DateToGMTString, 1033 "toGMTString", DateToGMTString,
1031 "toUTCString", DateToUTCString, 1034 "toUTCString", DateToUTCString,
1032 "getYear", DateGetYear, 1035 "getYear", DateGetYear,
1033 "setYear", DateSetYear 1036 "setYear", DateSetYear
1034 )); 1037 ));
1035 } 1038 }
1036 1039
1037 SetupDate(); 1040 SetupDate();
OLDNEW
« no previous file with comments | « no previous file | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698