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

Side by Side Diff: src/date.js

Issue 990883002: Hide Math function implementations in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove printf and unnecessary test case change. Created 5 years, 9 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/arraybuffer.js ('k') | src/harmony-string.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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declarations have been made 7 // This file relies on the fact that the following declarations have been made
8 // in v8natives.js: 8 // in v8natives.js:
9 // var $isFinite = GlobalIsFinite; 9 // var $isFinite = GlobalIsFinite;
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 + TwoDigitString(UTC_MIN(date)) + ':' 223 + TwoDigitString(UTC_MIN(date)) + ':'
224 + TwoDigitString(UTC_SEC(date)); 224 + TwoDigitString(UTC_SEC(date));
225 } 225 }
226 226
227 227
228 function LocalTimezoneString(date) { 228 function LocalTimezoneString(date) {
229 var timezone = LocalTimezone(UTC_DATE_VALUE(date)); 229 var timezone = LocalTimezone(UTC_DATE_VALUE(date));
230 230
231 var timezoneOffset = -TIMEZONE_OFFSET(date); 231 var timezoneOffset = -TIMEZONE_OFFSET(date);
232 var sign = (timezoneOffset >= 0) ? 1 : -1; 232 var sign = (timezoneOffset >= 0) ? 1 : -1;
233 var hours = FLOOR((sign * timezoneOffset)/60); 233 var hours = $floor((sign * timezoneOffset)/60);
234 var min = FLOOR((sign * timezoneOffset)%60); 234 var min = $floor((sign * timezoneOffset)%60);
235 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + 235 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
236 TwoDigitString(hours) + TwoDigitString(min); 236 TwoDigitString(hours) + TwoDigitString(min);
237 return gmt + ' (' + timezone + ')'; 237 return gmt + ' (' + timezone + ')';
238 } 238 }
239 239
240 240
241 function DatePrintString(date) { 241 function DatePrintString(date) {
242 return DateString(date) + ' ' + TimeString(date); 242 return DateString(date) + ' ' + TimeString(date);
243 } 243 }
244 244
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 // toUTCString. JSC does not do this, so for compatibility we do not 677 // toUTCString. JSC does not do this, so for compatibility we do not
678 // do that either. Instead, we create a new function whose name 678 // do that either. Instead, we create a new function whose name
679 // property will return toGMTString. 679 // property will return toGMTString.
680 function DateToGMTString() { 680 function DateToGMTString() {
681 return %_CallFunction(this, DateToUTCString); 681 return %_CallFunction(this, DateToUTCString);
682 } 682 }
683 683
684 684
685 function PadInt(n, digits) { 685 function PadInt(n, digits) {
686 if (digits == 1) return n; 686 if (digits == 1) return n;
687 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; 687 return n < %_MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n;
688 } 688 }
689 689
690 690
691 // ECMA 262 - 15.9.5.43 691 // ECMA 262 - 15.9.5.43
692 function DateToISOString() { 692 function DateToISOString() {
693 var t = UTC_DATE_VALUE(this); 693 var t = UTC_DATE_VALUE(this);
694 if (NUMBER_IS_NAN(t)) throw MakeRangeError("invalid_time_value", []); 694 if (NUMBER_IS_NAN(t)) throw MakeRangeError("invalid_time_value", []);
695 var year = this.getUTCFullYear(); 695 var year = this.getUTCFullYear();
696 var year_string; 696 var year_string;
697 if (year >= 0 && year <= 9999) { 697 if (year >= 0 && year <= 9999) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 "toGMTString", DateToGMTString, 818 "toGMTString", DateToGMTString,
819 "toUTCString", DateToUTCString, 819 "toUTCString", DateToUTCString,
820 "getYear", DateGetYear, 820 "getYear", DateGetYear,
821 "setYear", DateSetYear, 821 "setYear", DateSetYear,
822 "toISOString", DateToISOString, 822 "toISOString", DateToISOString,
823 "toJSON", DateToJSON 823 "toJSON", DateToJSON
824 )); 824 ));
825 } 825 }
826 826
827 SetUpDate(); 827 SetUpDate();
OLDNEW
« no previous file with comments | « src/arraybuffer.js ('k') | src/harmony-string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698