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

Side by Side Diff: src/date.js

Issue 1143993003: Use shared container to manage imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed test for no-snap Created 5 years, 7 months 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
« no previous file with comments | « src/contexts.h ('k') | src/generator.js » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in v8natives.js: 6 // in v8natives.js:
7 // var $isFinite = GlobalIsFinite; 7 // var $isFinite = GlobalIsFinite;
8 8
9 var $createDate; 9 var $createDate;
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 12
13 (function(global, shared, exports) { 13 (function(global, utils) {
14 14
15 "use strict"; 15 "use strict";
16 16
17 %CheckIsBootstrapping(); 17 %CheckIsBootstrapping();
18 18
19 // ------------------------------------------------------------------- 19 // -------------------------------------------------------------------
20 // Imports 20 // Imports
21 21
22 var GlobalDate = global.Date; 22 var GlobalDate = global.Date;
23 var InternalArray = shared.InternalArray; 23 var InternalArray = utils.InternalArray;
24
25 var MathAbs;
26 var MathFloor;
27
28 utils.Import(function(from) {
29 MathAbs = from.MathAbs;
30 MathFloor = from.MathFloor;
31 });
24 32
25 // ------------------------------------------------------------------- 33 // -------------------------------------------------------------------
26 34
27 // This file contains date support implemented in JavaScript. 35 // This file contains date support implemented in JavaScript.
28 36
29 var timezone_cache_time = NAN; 37 var timezone_cache_time = NAN;
30 var timezone_cache_timezone; 38 var timezone_cache_timezone;
31 39
32 function LocalTimezone(t) { 40 function LocalTimezone(t) {
33 if (NUMBER_IS_NAN(t)) return ""; 41 if (NUMBER_IS_NAN(t)) return "";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 102
95 103
96 // ECMA 262 - 15.9.1.13 104 // ECMA 262 - 15.9.1.13
97 function MakeDate(day, time) { 105 function MakeDate(day, time) {
98 var time = day * msPerDay + time; 106 var time = day * msPerDay + time;
99 // Some of our runtime funtions for computing UTC(time) rely on 107 // Some of our runtime funtions for computing UTC(time) rely on
100 // times not being significantly larger than MAX_TIME_MS. If there 108 // times not being significantly larger than MAX_TIME_MS. If there
101 // is no way that the time can be within range even after UTC 109 // is no way that the time can be within range even after UTC
102 // conversion we return NaN immediately instead of relying on 110 // conversion we return NaN immediately instead of relying on
103 // TimeClip to do it. 111 // TimeClip to do it.
104 if ($abs(time) > MAX_TIME_BEFORE_UTC) return NAN; 112 if (MathAbs(time) > MAX_TIME_BEFORE_UTC) return NAN;
105 return time; 113 return time;
106 } 114 }
107 115
108 116
109 // ECMA 262 - 15.9.1.14 117 // ECMA 262 - 15.9.1.14
110 function TimeClip(time) { 118 function TimeClip(time) {
111 if (!$isFinite(time)) return NAN; 119 if (!$isFinite(time)) return NAN;
112 if ($abs(time) > MAX_TIME_MS) return NAN; 120 if (MathAbs(time) > MAX_TIME_MS) return NAN;
113 return TO_INTEGER(time); 121 return TO_INTEGER(time);
114 } 122 }
115 123
116 124
117 // The Date cache is used to limit the cost of parsing the same Date 125 // The Date cache is used to limit the cost of parsing the same Date
118 // strings over and over again. 126 // strings over and over again.
119 var Date_cache = { 127 var Date_cache = {
120 // Cached time value. 128 // Cached time value.
121 time: 0, 129 time: 0,
122 // String input for which the cached time is valid. 130 // String input for which the cached time is valid.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 + TwoDigitString(UTC_MIN(date)) + ':' 237 + TwoDigitString(UTC_MIN(date)) + ':'
230 + TwoDigitString(UTC_SEC(date)); 238 + TwoDigitString(UTC_SEC(date));
231 } 239 }
232 240
233 241
234 function LocalTimezoneString(date) { 242 function LocalTimezoneString(date) {
235 var timezone = LocalTimezone(UTC_DATE_VALUE(date)); 243 var timezone = LocalTimezone(UTC_DATE_VALUE(date));
236 244
237 var timezoneOffset = -TIMEZONE_OFFSET(date); 245 var timezoneOffset = -TIMEZONE_OFFSET(date);
238 var sign = (timezoneOffset >= 0) ? 1 : -1; 246 var sign = (timezoneOffset >= 0) ? 1 : -1;
239 var hours = $floor((sign * timezoneOffset)/60); 247 var hours = MathFloor((sign * timezoneOffset)/60);
240 var min = $floor((sign * timezoneOffset)%60); 248 var min = MathFloor((sign * timezoneOffset)%60);
241 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + 249 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
242 TwoDigitString(hours) + TwoDigitString(min); 250 TwoDigitString(hours) + TwoDigitString(min);
243 return gmt + ' (' + timezone + ')'; 251 return gmt + ' (' + timezone + ')';
244 } 252 }
245 253
246 254
247 function DatePrintString(date) { 255 function DatePrintString(date) {
248 return DateString(date) + ' ' + TimeString(date); 256 return DateString(date) + ' ' + TimeString(date);
249 } 257 }
250 258
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 "getYear", DateGetYear, 831 "getYear", DateGetYear,
824 "setYear", DateSetYear, 832 "setYear", DateSetYear,
825 "toISOString", DateToISOString, 833 "toISOString", DateToISOString,
826 "toJSON", DateToJSON 834 "toJSON", DateToJSON
827 ]); 835 ]);
828 836
829 // Expose to the global scope. 837 // Expose to the global scope.
830 $createDate = CreateDate; 838 $createDate = CreateDate;
831 839
832 }) 840 })
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/generator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698