}
function LocalTimeNoCheck(time) {
+ if (time < -MAX_TIME_MS || time > MAX_TIME_MS) {
+ return $NaN;
+ }
+
// Inline the DST offset cache checks for speed.
var cache = DST_offset_cache;
if (cache.start <= time && time <= cache.end) {
function YearFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
function MonthFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
%DateYMDFromTime(t, ymd_from_time_cache);
function DateFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
# REGEXP_NUMBER_OF_CAPTURES
macro NUMBER_OF_CAPTURES(array) = ((array)[0]);
+# Limit according to ECMA 262 15.9.1.1
+const MAX_TIME_MS = 8640000000000000;
+
# Gets the value of a Date object. If arg is not a Date object
# a type error is thrown.
macro DATE_VALUE(arg) = (%_ClassOf(arg) === 'Date' ? %_ValueOf(arg) : ThrowDateTypeError());
var dMax = new Date(8.64e15);
assertEquals(8.64e15, dMax.getTime());
+assertEquals(275760, dMax.getFullYear());
+assertEquals(8, dMax.getMonth());
+assertEquals(13, dMax.getDate());
var dOverflow = new Date(8.64e15+1);
assertTrue(isNaN(dOverflow.getTime()));
var dMin = new Date(-8.64e15);
assertEquals(-8.64e15, dMin.getTime());
+assertEquals(-271821, dMin.getFullYear());
+assertEquals(3, dMin.getMonth());
+assertEquals(20, dMin.getDate());
var dUnderflow = new Date(-8.64e15-1);
assertTrue(isNaN(dUnderflow.getTime()));