| OLD | NEW |
| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return Modulo(DAY(time) + 4, 7); | 231 return Modulo(DAY(time) + 4, 7); |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 function LocalTime(time) { | 235 function LocalTime(time) { |
| 236 if (NUMBER_IS_NAN(time)) return time; | 236 if (NUMBER_IS_NAN(time)) return time; |
| 237 // DaylightSavingsOffset called before local_time_offset used. | 237 // DaylightSavingsOffset called before local_time_offset used. |
| 238 return time + DaylightSavingsOffset(time) + local_time_offset; | 238 return time + DaylightSavingsOffset(time) + local_time_offset; |
| 239 } | 239 } |
| 240 | 240 |
| 241 |
| 242 var ltcache = { |
| 243 key: null, |
| 244 val: null |
| 245 }; |
| 246 |
| 241 function LocalTimeNoCheck(time) { | 247 function LocalTimeNoCheck(time) { |
| 248 var ltc = ltcache; |
| 249 if (%_ObjectEquals(time, ltc.key)) return ltc.val; |
| 242 if (time < -MAX_TIME_MS || time > MAX_TIME_MS) { | 250 if (time < -MAX_TIME_MS || time > MAX_TIME_MS) { |
| 243 return $NaN; | 251 return $NaN; |
| 244 } | 252 } |
| 245 | 253 |
| 246 // Inline the DST offset cache checks for speed. | 254 // Inline the DST offset cache checks for speed. |
| 247 // The cache is hit, or DaylightSavingsOffset is called, | 255 // The cache is hit, or DaylightSavingsOffset is called, |
| 248 // before local_time_offset is used. | 256 // before local_time_offset is used. |
| 249 var cache = DST_offset_cache; | 257 var cache = DST_offset_cache; |
| 250 if (cache.start <= time && time <= cache.end) { | 258 if (cache.start <= time && time <= cache.end) { |
| 251 var dst_offset = cache.offset; | 259 var dst_offset = cache.offset; |
| 252 } else { | 260 } else { |
| 253 var dst_offset = DaylightSavingsOffset(time); | 261 var dst_offset = DaylightSavingsOffset(time); |
| 254 } | 262 } |
| 255 return time + local_time_offset + dst_offset; | 263 ltc.key = time; |
| 264 return (ltc.val = time + local_time_offset + dst_offset); |
| 256 } | 265 } |
| 257 | 266 |
| 258 | 267 |
| 259 function UTC(time) { | 268 function UTC(time) { |
| 260 if (NUMBER_IS_NAN(time)) return time; | 269 if (NUMBER_IS_NAN(time)) return time; |
| 261 // local_time_offset is needed before the call to DaylightSavingsOffset, | 270 // local_time_offset is needed before the call to DaylightSavingsOffset, |
| 262 // so it may be uninitialized. | 271 // so it may be uninitialized. |
| 263 if (IS_UNDEFINED(local_time_offset)) { | 272 if (IS_UNDEFINED(local_time_offset)) { |
| 264 local_time_offset = %DateLocalTimeOffset(); | 273 local_time_offset = %DateLocalTimeOffset(); |
| 265 } | 274 } |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 "toGMTString", DateToGMTString, | 1128 "toGMTString", DateToGMTString, |
| 1120 "toUTCString", DateToUTCString, | 1129 "toUTCString", DateToUTCString, |
| 1121 "getYear", DateGetYear, | 1130 "getYear", DateGetYear, |
| 1122 "setYear", DateSetYear, | 1131 "setYear", DateSetYear, |
| 1123 "toISOString", DateToISOString, | 1132 "toISOString", DateToISOString, |
| 1124 "toJSON", DateToJSON | 1133 "toJSON", DateToJSON |
| 1125 )); | 1134 )); |
| 1126 } | 1135 } |
| 1127 | 1136 |
| 1128 SetupDate(); | 1137 SetupDate(); |
| OLD | NEW |