mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Bug 703458: Handle NaN in Date accessors.
This commit is contained in:
85
jsdate.c
85
jsdate.c
@@ -491,103 +491,154 @@ static void Dp_toISOString(js_State *J)
|
||||
static void Dp_getFullYear(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, YearFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, YearFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getMonth(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, MonthFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, MonthFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getDate(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, DateFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, DateFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getDay(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, WeekDay(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, WeekDay(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getHours(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, HourFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, HourFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getMinutes(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, MinFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, MinFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getSeconds(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, SecFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, SecFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getMilliseconds(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, msFromTime(LocalTime(t)));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, msFromTime(LocalTime(t)));
|
||||
}
|
||||
|
||||
static void Dp_getUTCFullYear(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, YearFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, YearFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCMonth(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, MonthFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, MonthFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCDate(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, DateFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, DateFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCDay(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, WeekDay(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, WeekDay(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCHours(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, HourFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, HourFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCMinutes(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, MinFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, MinFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCSeconds(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, SecFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, SecFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getUTCMilliseconds(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, msFromTime(t));
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, msFromTime(t));
|
||||
}
|
||||
|
||||
static void Dp_getTimezoneOffset(js_State *J)
|
||||
{
|
||||
double t = js_todate(J, 0);
|
||||
js_pushnumber(J, (t - LocalTime(t)) / msPerMinute);
|
||||
if (isnan(t))
|
||||
js_pushnumber(J, NAN);
|
||||
else
|
||||
js_pushnumber(J, (t - LocalTime(t)) / msPerMinute);
|
||||
}
|
||||
|
||||
static void Dp_setTime(js_State *J)
|
||||
|
||||
Reference in New Issue
Block a user