summaryrefslogtreecommitdiff
path: root/deps/v8/src/date.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/date.js')
-rw-r--r--deps/v8/src/date.js161
1 files changed, 83 insertions, 78 deletions
diff --git a/deps/v8/src/date.js b/deps/v8/src/date.js
index 40ab1d25d6..eafe798500 100644
--- a/deps/v8/src/date.js
+++ b/deps/v8/src/date.js
@@ -2,16 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-"use strict";
-
// This file relies on the fact that the following declarations have been made
// in v8natives.js:
// var $isFinite = GlobalIsFinite;
-var $Date = global.Date;
+var $createDate;
// -------------------------------------------------------------------
+(function() {
+
+"use strict";
+
+%CheckIsBootstrapping();
+
+var GlobalDate = global.Date;
+
// This file contains date support implemented in JavaScript.
// Helper function to throw error.
@@ -19,7 +25,6 @@ function ThrowDateTypeError() {
throw new $TypeError('this is not a Date object.');
}
-
var timezone_cache_time = NAN;
var timezone_cache_timezone;
@@ -121,7 +126,7 @@ var Date_cache = {
function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
if (!%_IsConstructCall()) {
// ECMA 262 - 15.9.2
- return (new $Date()).toString();
+ return (new GlobalDate()).toString();
}
// ECMA 262 - 15.9.3
@@ -230,8 +235,8 @@ function LocalTimezoneString(date) {
var timezoneOffset = -TIMEZONE_OFFSET(date);
var sign = (timezoneOffset >= 0) ? 1 : -1;
- var hours = FLOOR((sign * timezoneOffset)/60);
- var min = FLOOR((sign * timezoneOffset)%60);
+ var hours = $floor((sign * timezoneOffset)/60);
+ var min = $floor((sign * timezoneOffset)%60);
var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
TwoDigitString(hours) + TwoDigitString(min);
return gmt + ' (' + timezone + ')';
@@ -684,7 +689,7 @@ function DateToGMTString() {
function PadInt(n, digits) {
if (digits == 1) return n;
- return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n;
+ return n < %_MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n;
}
@@ -731,6 +736,7 @@ var date_cache_version = NAN;
function CheckDateCacheCurrent() {
if (!date_cache_version_holder) {
date_cache_version_holder = %DateCacheVersion();
+ if (!date_cache_version_holder) return;
}
if (date_cache_version_holder[0] == date_cache_version) {
return;
@@ -748,79 +754,78 @@ function CheckDateCacheCurrent() {
function CreateDate(time) {
- var date = new $Date();
+ var date = new GlobalDate();
date.setTime(time);
return date;
}
// -------------------------------------------------------------------
-function SetUpDate() {
- %CheckIsBootstrapping();
-
- %SetCode($Date, DateConstructor);
- %FunctionSetPrototype($Date, new $Date(NAN));
-
- // Set up non-enumerable properties of the Date object itself.
- InstallFunctions($Date, DONT_ENUM, $Array(
- "UTC", DateUTC,
- "parse", DateParse,
- "now", DateNow
- ));
-
- // Set up non-enumerable constructor property of the Date prototype object.
- %AddNamedProperty($Date.prototype, "constructor", $Date, DONT_ENUM);
-
- // Set up non-enumerable functions of the Date prototype object and
- // set their names.
- InstallFunctions($Date.prototype, DONT_ENUM, $Array(
- "toString", DateToString,
- "toDateString", DateToDateString,
- "toTimeString", DateToTimeString,
- "toLocaleString", DateToLocaleString,
- "toLocaleDateString", DateToLocaleDateString,
- "toLocaleTimeString", DateToLocaleTimeString,
- "valueOf", DateValueOf,
- "getTime", DateGetTime,
- "getFullYear", DateGetFullYear,
- "getUTCFullYear", DateGetUTCFullYear,
- "getMonth", DateGetMonth,
- "getUTCMonth", DateGetUTCMonth,
- "getDate", DateGetDate,
- "getUTCDate", DateGetUTCDate,
- "getDay", DateGetDay,
- "getUTCDay", DateGetUTCDay,
- "getHours", DateGetHours,
- "getUTCHours", DateGetUTCHours,
- "getMinutes", DateGetMinutes,
- "getUTCMinutes", DateGetUTCMinutes,
- "getSeconds", DateGetSeconds,
- "getUTCSeconds", DateGetUTCSeconds,
- "getMilliseconds", DateGetMilliseconds,
- "getUTCMilliseconds", DateGetUTCMilliseconds,
- "getTimezoneOffset", DateGetTimezoneOffset,
- "setTime", DateSetTime,
- "setMilliseconds", DateSetMilliseconds,
- "setUTCMilliseconds", DateSetUTCMilliseconds,
- "setSeconds", DateSetSeconds,
- "setUTCSeconds", DateSetUTCSeconds,
- "setMinutes", DateSetMinutes,
- "setUTCMinutes", DateSetUTCMinutes,
- "setHours", DateSetHours,
- "setUTCHours", DateSetUTCHours,
- "setDate", DateSetDate,
- "setUTCDate", DateSetUTCDate,
- "setMonth", DateSetMonth,
- "setUTCMonth", DateSetUTCMonth,
- "setFullYear", DateSetFullYear,
- "setUTCFullYear", DateSetUTCFullYear,
- "toGMTString", DateToGMTString,
- "toUTCString", DateToUTCString,
- "getYear", DateGetYear,
- "setYear", DateSetYear,
- "toISOString", DateToISOString,
- "toJSON", DateToJSON
- ));
-}
-
-SetUpDate();
+%SetCode(GlobalDate, DateConstructor);
+%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
+
+// Set up non-enumerable properties of the Date object itself.
+InstallFunctions(GlobalDate, DONT_ENUM, $Array(
+ "UTC", DateUTC,
+ "parse", DateParse,
+ "now", DateNow
+));
+
+// Set up non-enumerable constructor property of the Date prototype object.
+%AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM);
+
+// Set up non-enumerable functions of the Date prototype object and
+// set their names.
+InstallFunctions(GlobalDate.prototype, DONT_ENUM, $Array(
+ "toString", DateToString,
+ "toDateString", DateToDateString,
+ "toTimeString", DateToTimeString,
+ "toLocaleString", DateToLocaleString,
+ "toLocaleDateString", DateToLocaleDateString,
+ "toLocaleTimeString", DateToLocaleTimeString,
+ "valueOf", DateValueOf,
+ "getTime", DateGetTime,
+ "getFullYear", DateGetFullYear,
+ "getUTCFullYear", DateGetUTCFullYear,
+ "getMonth", DateGetMonth,
+ "getUTCMonth", DateGetUTCMonth,
+ "getDate", DateGetDate,
+ "getUTCDate", DateGetUTCDate,
+ "getDay", DateGetDay,
+ "getUTCDay", DateGetUTCDay,
+ "getHours", DateGetHours,
+ "getUTCHours", DateGetUTCHours,
+ "getMinutes", DateGetMinutes,
+ "getUTCMinutes", DateGetUTCMinutes,
+ "getSeconds", DateGetSeconds,
+ "getUTCSeconds", DateGetUTCSeconds,
+ "getMilliseconds", DateGetMilliseconds,
+ "getUTCMilliseconds", DateGetUTCMilliseconds,
+ "getTimezoneOffset", DateGetTimezoneOffset,
+ "setTime", DateSetTime,
+ "setMilliseconds", DateSetMilliseconds,
+ "setUTCMilliseconds", DateSetUTCMilliseconds,
+ "setSeconds", DateSetSeconds,
+ "setUTCSeconds", DateSetUTCSeconds,
+ "setMinutes", DateSetMinutes,
+ "setUTCMinutes", DateSetUTCMinutes,
+ "setHours", DateSetHours,
+ "setUTCHours", DateSetUTCHours,
+ "setDate", DateSetDate,
+ "setUTCDate", DateSetUTCDate,
+ "setMonth", DateSetMonth,
+ "setUTCMonth", DateSetUTCMonth,
+ "setFullYear", DateSetFullYear,
+ "setUTCFullYear", DateSetUTCFullYear,
+ "toGMTString", DateToGMTString,
+ "toUTCString", DateToUTCString,
+ "getYear", DateGetYear,
+ "setYear", DateSetYear,
+ "toISOString", DateToISOString,
+ "toJSON", DateToJSON
+));
+
+// Expose to the global scope.
+$createDate = CreateDate;
+
+})();