aboutsummaryrefslogtreecommitdiff
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.js135
1 files changed, 65 insertions, 70 deletions
diff --git a/deps/v8/src/date.js b/deps/v8/src/date.js
index eafe798500..0cd18250e4 100644
--- a/deps/v8/src/date.js
+++ b/deps/v8/src/date.js
@@ -10,7 +10,7 @@ var $createDate;
// -------------------------------------------------------------------
-(function() {
+(function(global, shared, exports) {
"use strict";
@@ -20,11 +20,6 @@ var GlobalDate = global.Date;
// This file contains date support implemented in JavaScript.
-// Helper function to throw error.
-function ThrowDateTypeError() {
- throw new $TypeError('this is not a Date object.');
-}
-
var timezone_cache_time = NAN;
var timezone_cache_timezone;
@@ -161,18 +156,18 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
// argument. We therefore use NUMBER_HINT for the conversion,
// which is the default for everything else than Date objects.
// This makes us behave like KJS and SpiderMonkey.
- var time = ToPrimitive(year, NUMBER_HINT);
- value = IS_STRING(time) ? DateParse(time) : ToNumber(time);
+ var time = $toPrimitive(year, NUMBER_HINT);
+ value = IS_STRING(time) ? DateParse(time) : $toNumber(time);
}
SET_UTC_DATE_VALUE(this, value);
} else {
- year = ToNumber(year);
- month = ToNumber(month);
- date = argc > 2 ? ToNumber(date) : 1;
- hours = argc > 3 ? ToNumber(hours) : 0;
- minutes = argc > 4 ? ToNumber(minutes) : 0;
- seconds = argc > 5 ? ToNumber(seconds) : 0;
- ms = argc > 6 ? ToNumber(ms) : 0;
+ year = $toNumber(year);
+ month = $toNumber(month);
+ date = argc > 2 ? $toNumber(date) : 1;
+ hours = argc > 3 ? $toNumber(hours) : 0;
+ minutes = argc > 4 ? $toNumber(minutes) : 0;
+ seconds = argc > 5 ? $toNumber(seconds) : 0;
+ ms = argc > 6 ? $toNumber(ms) : 0;
year = (!NUMBER_IS_NAN(year) &&
0 <= TO_INTEGER(year) &&
TO_INTEGER(year) <= 99) ? 1900 + TO_INTEGER(year) : year;
@@ -250,11 +245,11 @@ function DatePrintString(date) {
// -------------------------------------------------------------------
// Reused output buffer. Used when parsing date strings.
-var parse_buffer = $Array(8);
+var parse_buffer = new InternalArray(8);
// ECMA 262 - 15.9.4.2
function DateParse(string) {
- var arr = %DateParseString(ToString(string), parse_buffer);
+ var arr = %DateParseString($toString(string), parse_buffer);
if (IS_NULL(arr)) return NAN;
var day = MakeDay(arr[0], arr[1], arr[2]);
@@ -271,14 +266,14 @@ function DateParse(string) {
// ECMA 262 - 15.9.4.3
function DateUTC(year, month, date, hours, minutes, seconds, ms) {
- year = ToNumber(year);
- month = ToNumber(month);
+ year = $toNumber(year);
+ month = $toNumber(month);
var argc = %_ArgumentsLength();
- date = argc > 2 ? ToNumber(date) : 1;
- hours = argc > 3 ? ToNumber(hours) : 0;
- minutes = argc > 4 ? ToNumber(minutes) : 0;
- seconds = argc > 5 ? ToNumber(seconds) : 0;
- ms = argc > 6 ? ToNumber(ms) : 0;
+ date = argc > 2 ? $toNumber(date) : 1;
+ hours = argc > 3 ? $toNumber(hours) : 0;
+ minutes = argc > 4 ? $toNumber(minutes) : 0;
+ seconds = argc > 5 ? $toNumber(seconds) : 0;
+ ms = argc > 6 ? $toNumber(ms) : 0;
year = (!NUMBER_IS_NAN(year) &&
0 <= TO_INTEGER(year) &&
TO_INTEGER(year) <= 99) ? 1900 + TO_INTEGER(year) : year;
@@ -459,7 +454,7 @@ function DateGetTimezoneOffset() {
// ECMA 262 - 15.9.5.27
function DateSetTime(ms) {
CHECK_DATE(this);
- SET_UTC_DATE_VALUE(this, ToNumber(ms));
+ SET_UTC_DATE_VALUE(this, $toNumber(ms));
return UTC_DATE_VALUE(this);
}
@@ -467,7 +462,7 @@ function DateSetTime(ms) {
// ECMA 262 - 15.9.5.28
function DateSetMilliseconds(ms) {
var t = LOCAL_DATE_VALUE(this);
- ms = ToNumber(ms);
+ ms = $toNumber(ms);
var time = MakeTime(LOCAL_HOUR(this), LOCAL_MIN(this), LOCAL_SEC(this), ms);
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
}
@@ -476,7 +471,7 @@ function DateSetMilliseconds(ms) {
// ECMA 262 - 15.9.5.29
function DateSetUTCMilliseconds(ms) {
var t = UTC_DATE_VALUE(this);
- ms = ToNumber(ms);
+ ms = $toNumber(ms);
var time = MakeTime(UTC_HOUR(this),
UTC_MIN(this),
UTC_SEC(this),
@@ -488,8 +483,8 @@ function DateSetUTCMilliseconds(ms) {
// ECMA 262 - 15.9.5.30
function DateSetSeconds(sec, ms) {
var t = LOCAL_DATE_VALUE(this);
- sec = ToNumber(sec);
- ms = %_ArgumentsLength() < 2 ? LOCAL_MS(this) : ToNumber(ms);
+ sec = $toNumber(sec);
+ ms = %_ArgumentsLength() < 2 ? LOCAL_MS(this) : $toNumber(ms);
var time = MakeTime(LOCAL_HOUR(this), LOCAL_MIN(this), sec, ms);
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
}
@@ -498,8 +493,8 @@ function DateSetSeconds(sec, ms) {
// ECMA 262 - 15.9.5.31
function DateSetUTCSeconds(sec, ms) {
var t = UTC_DATE_VALUE(this);
- sec = ToNumber(sec);
- ms = %_ArgumentsLength() < 2 ? UTC_MS(this) : ToNumber(ms);
+ sec = $toNumber(sec);
+ ms = %_ArgumentsLength() < 2 ? UTC_MS(this) : $toNumber(ms);
var time = MakeTime(UTC_HOUR(this), UTC_MIN(this), sec, ms);
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
}
@@ -508,10 +503,10 @@ function DateSetUTCSeconds(sec, ms) {
// ECMA 262 - 15.9.5.33
function DateSetMinutes(min, sec, ms) {
var t = LOCAL_DATE_VALUE(this);
- min = ToNumber(min);
+ min = $toNumber(min);
var argc = %_ArgumentsLength();
- sec = argc < 2 ? LOCAL_SEC(this) : ToNumber(sec);
- ms = argc < 3 ? LOCAL_MS(this) : ToNumber(ms);
+ sec = argc < 2 ? LOCAL_SEC(this) : $toNumber(sec);
+ ms = argc < 3 ? LOCAL_MS(this) : $toNumber(ms);
var time = MakeTime(LOCAL_HOUR(this), min, sec, ms);
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
}
@@ -520,10 +515,10 @@ function DateSetMinutes(min, sec, ms) {
// ECMA 262 - 15.9.5.34
function DateSetUTCMinutes(min, sec, ms) {
var t = UTC_DATE_VALUE(this);
- min = ToNumber(min);
+ min = $toNumber(min);
var argc = %_ArgumentsLength();
- sec = argc < 2 ? UTC_SEC(this) : ToNumber(sec);
- ms = argc < 3 ? UTC_MS(this) : ToNumber(ms);
+ sec = argc < 2 ? UTC_SEC(this) : $toNumber(sec);
+ ms = argc < 3 ? UTC_MS(this) : $toNumber(ms);
var time = MakeTime(UTC_HOUR(this), min, sec, ms);
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
}
@@ -532,11 +527,11 @@ function DateSetUTCMinutes(min, sec, ms) {
// ECMA 262 - 15.9.5.35
function DateSetHours(hour, min, sec, ms) {
var t = LOCAL_DATE_VALUE(this);
- hour = ToNumber(hour);
+ hour = $toNumber(hour);
var argc = %_ArgumentsLength();
- min = argc < 2 ? LOCAL_MIN(this) : ToNumber(min);
- sec = argc < 3 ? LOCAL_SEC(this) : ToNumber(sec);
- ms = argc < 4 ? LOCAL_MS(this) : ToNumber(ms);
+ min = argc < 2 ? LOCAL_MIN(this) : $toNumber(min);
+ sec = argc < 3 ? LOCAL_SEC(this) : $toNumber(sec);
+ ms = argc < 4 ? LOCAL_MS(this) : $toNumber(ms);
var time = MakeTime(hour, min, sec, ms);
return SET_LOCAL_DATE_VALUE(this, MakeDate(LOCAL_DAYS(this), time));
}
@@ -545,11 +540,11 @@ function DateSetHours(hour, min, sec, ms) {
// ECMA 262 - 15.9.5.34
function DateSetUTCHours(hour, min, sec, ms) {
var t = UTC_DATE_VALUE(this);
- hour = ToNumber(hour);
+ hour = $toNumber(hour);
var argc = %_ArgumentsLength();
- min = argc < 2 ? UTC_MIN(this) : ToNumber(min);
- sec = argc < 3 ? UTC_SEC(this) : ToNumber(sec);
- ms = argc < 4 ? UTC_MS(this) : ToNumber(ms);
+ min = argc < 2 ? UTC_MIN(this) : $toNumber(min);
+ sec = argc < 3 ? UTC_SEC(this) : $toNumber(sec);
+ ms = argc < 4 ? UTC_MS(this) : $toNumber(ms);
var time = MakeTime(hour, min, sec, ms);
return SET_UTC_DATE_VALUE(this, MakeDate(UTC_DAYS(this), time));
}
@@ -558,7 +553,7 @@ function DateSetUTCHours(hour, min, sec, ms) {
// ECMA 262 - 15.9.5.36
function DateSetDate(date) {
var t = LOCAL_DATE_VALUE(this);
- date = ToNumber(date);
+ date = $toNumber(date);
var day = MakeDay(LOCAL_YEAR(this), LOCAL_MONTH(this), date);
return SET_LOCAL_DATE_VALUE(this, MakeDate(day, LOCAL_TIME_IN_DAY(this)));
}
@@ -567,7 +562,7 @@ function DateSetDate(date) {
// ECMA 262 - 15.9.5.37
function DateSetUTCDate(date) {
var t = UTC_DATE_VALUE(this);
- date = ToNumber(date);
+ date = $toNumber(date);
var day = MakeDay(UTC_YEAR(this), UTC_MONTH(this), date);
return SET_UTC_DATE_VALUE(this, MakeDate(day, UTC_TIME_IN_DAY(this)));
}
@@ -576,8 +571,8 @@ function DateSetUTCDate(date) {
// ECMA 262 - 15.9.5.38
function DateSetMonth(month, date) {
var t = LOCAL_DATE_VALUE(this);
- month = ToNumber(month);
- date = %_ArgumentsLength() < 2 ? LOCAL_DAY(this) : ToNumber(date);
+ month = $toNumber(month);
+ date = %_ArgumentsLength() < 2 ? LOCAL_DAY(this) : $toNumber(date);
var day = MakeDay(LOCAL_YEAR(this), month, date);
return SET_LOCAL_DATE_VALUE(this, MakeDate(day, LOCAL_TIME_IN_DAY(this)));
}
@@ -586,8 +581,8 @@ function DateSetMonth(month, date) {
// ECMA 262 - 15.9.5.39
function DateSetUTCMonth(month, date) {
var t = UTC_DATE_VALUE(this);
- month = ToNumber(month);
- date = %_ArgumentsLength() < 2 ? UTC_DAY(this) : ToNumber(date);
+ month = $toNumber(month);
+ date = %_ArgumentsLength() < 2 ? UTC_DAY(this) : $toNumber(date);
var day = MakeDay(UTC_YEAR(this), month, date);
return SET_UTC_DATE_VALUE(this, MakeDate(day, UTC_TIME_IN_DAY(this)));
}
@@ -596,16 +591,16 @@ function DateSetUTCMonth(month, date) {
// ECMA 262 - 15.9.5.40
function DateSetFullYear(year, month, date) {
var t = LOCAL_DATE_VALUE(this);
- year = ToNumber(year);
+ year = $toNumber(year);
var argc = %_ArgumentsLength();
var time ;
if (NUMBER_IS_NAN(t)) {
- month = argc < 2 ? 0 : ToNumber(month);
- date = argc < 3 ? 1 : ToNumber(date);
+ month = argc < 2 ? 0 : $toNumber(month);
+ date = argc < 3 ? 1 : $toNumber(date);
time = 0;
} else {
- month = argc < 2 ? LOCAL_MONTH(this) : ToNumber(month);
- date = argc < 3 ? LOCAL_DAY(this) : ToNumber(date);
+ month = argc < 2 ? LOCAL_MONTH(this) : $toNumber(month);
+ date = argc < 3 ? LOCAL_DAY(this) : $toNumber(date);
time = LOCAL_TIME_IN_DAY(this);
}
var day = MakeDay(year, month, date);
@@ -616,16 +611,16 @@ function DateSetFullYear(year, month, date) {
// ECMA 262 - 15.9.5.41
function DateSetUTCFullYear(year, month, date) {
var t = UTC_DATE_VALUE(this);
- year = ToNumber(year);
+ year = $toNumber(year);
var argc = %_ArgumentsLength();
var time ;
if (NUMBER_IS_NAN(t)) {
- month = argc < 2 ? 0 : ToNumber(month);
- date = argc < 3 ? 1 : ToNumber(date);
+ month = argc < 2 ? 0 : $toNumber(month);
+ date = argc < 3 ? 1 : $toNumber(date);
time = 0;
} else {
- month = argc < 2 ? UTC_MONTH(this) : ToNumber(month);
- date = argc < 3 ? UTC_DAY(this) : ToNumber(date);
+ month = argc < 2 ? UTC_MONTH(this) : $toNumber(month);
+ date = argc < 3 ? UTC_DAY(this) : $toNumber(date);
time = UTC_TIME_IN_DAY(this);
}
var day = MakeDay(year, month, date);
@@ -655,7 +650,7 @@ function DateGetYear() {
// ECMA 262 - B.2.5
function DateSetYear(year) {
CHECK_DATE(this);
- year = ToNumber(year);
+ year = $toNumber(year);
if (NUMBER_IS_NAN(year)) return SET_UTC_DATE_VALUE(this, NAN);
year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99)
? 1900 + TO_INTEGER(year) : year;
@@ -696,7 +691,7 @@ function PadInt(n, digits) {
// ECMA 262 - 15.9.5.43
function DateToISOString() {
var t = UTC_DATE_VALUE(this);
- if (NUMBER_IS_NAN(t)) throw MakeRangeError("invalid_time_value", []);
+ if (NUMBER_IS_NAN(t)) throw MakeRangeError(kInvalidTimeValue);
var year = this.getUTCFullYear();
var year_string;
if (year >= 0 && year <= 9999) {
@@ -720,8 +715,8 @@ function DateToISOString() {
function DateToJSON(key) {
- var o = ToObject(this);
- var tv = DefaultNumber(o);
+ var o = $toObject(this);
+ var tv = $defaultNumber(o);
if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) {
return null;
}
@@ -765,18 +760,18 @@ function CreateDate(time) {
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself.
-InstallFunctions(GlobalDate, DONT_ENUM, $Array(
+$installFunctions(GlobalDate, DONT_ENUM, [
"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(
+$installFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString,
"toDateString", DateToDateString,
"toTimeString", DateToTimeString,
@@ -823,9 +818,9 @@ InstallFunctions(GlobalDate.prototype, DONT_ENUM, $Array(
"setYear", DateSetYear,
"toISOString", DateToISOString,
"toJSON", DateToJSON
-));
+]);
// Expose to the global scope.
$createDate = CreateDate;
-})();
+})