Improve date internals (#4593)
- Optimize year from time calculation - Force arithmetic operations to int32_t/int64_t whenever possible - Optimize number conversion in date parse - Cache local TZA of the date object - Fix a bug in Date.parse timezone parsing JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -31,6 +31,22 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_DATE_ROUTINE_START = 0,
|
||||
ECMA_DATE_ROUTINE_PARSE,
|
||||
ECMA_DATE_ROUTINE_UTC,
|
||||
ECMA_DATE_ROUTINE_NOW,
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -45,6 +61,26 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Encode minimum/maximum limits
|
||||
*
|
||||
* See: ecma_date_parse_date_chars
|
||||
*
|
||||
* @param min: 8 bits unsigned number
|
||||
* @param max: 24 bits unsigned number
|
||||
*/
|
||||
#define ECMA_DATE_LIMIT(min, max) (min << 24 | max)
|
||||
|
||||
/**
|
||||
* Decode the minimum value from the encoded limit
|
||||
*/
|
||||
#define ECMA_DATE_LIMIT_MIN(limit) (limit >> 24)
|
||||
|
||||
/**
|
||||
* Decode the maximum value from the encoded limit
|
||||
*/
|
||||
#define ECMA_DATE_LIMIT_MAX(limit) (limit & ((1 << 24) - 1))
|
||||
|
||||
/**
|
||||
* Helper function to try to parse a part of a date string
|
||||
*
|
||||
@@ -54,28 +90,37 @@ static ecma_number_t
|
||||
ecma_date_parse_date_chars (const lit_utf8_byte_t **str_p, /**< pointer to the cesu8 string */
|
||||
const lit_utf8_byte_t *str_end_p, /**< pointer to the end of the string */
|
||||
uint32_t num_of_chars, /**< number of characters to read and convert */
|
||||
uint32_t min, /**< minimum valid value */
|
||||
uint32_t max) /**< maximum valid value */
|
||||
uint32_t limit) /**< minimum/maximum valid value */
|
||||
{
|
||||
JERRY_ASSERT (num_of_chars > 0);
|
||||
const lit_utf8_byte_t *str_start_p = *str_p;
|
||||
JERRY_ASSERT (num_of_chars > 0 && num_of_chars <= 6);
|
||||
|
||||
while (num_of_chars--)
|
||||
{
|
||||
if (*str_p >= str_end_p || !lit_char_is_decimal_digit (lit_cesu8_read_next (str_p)))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t parsed_number = ecma_utf8_string_to_number (str_start_p, (lit_utf8_size_t) (*str_p - str_start_p), 0);
|
||||
|
||||
if (parsed_number < min || parsed_number > max)
|
||||
if (*str_p + num_of_chars > str_end_p)
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
return parsed_number;
|
||||
str_end_p = *str_p + num_of_chars;
|
||||
|
||||
uint32_t num = 0;
|
||||
|
||||
while (num_of_chars--)
|
||||
{
|
||||
lit_utf8_byte_t c = **str_p;
|
||||
if (!lit_char_is_decimal_digit (c))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
num = (num * 10) + (uint32_t) ((c - LIT_CHAR_0));
|
||||
(*str_p)++;
|
||||
}
|
||||
|
||||
if (num >= ECMA_DATE_LIMIT_MIN (limit) && num <= ECMA_DATE_LIMIT_MAX (limit))
|
||||
{
|
||||
return (ecma_number_t) num;
|
||||
}
|
||||
|
||||
return ecma_number_make_nan ();
|
||||
} /* ecma_date_parse_date_chars */
|
||||
|
||||
/**
|
||||
@@ -129,14 +174,10 @@ ecma_date_parse_year (const lit_utf8_byte_t **str_p, /**< pointer to the cesu8 s
|
||||
str_start_p++;
|
||||
}
|
||||
|
||||
if (str_start_p - *str_p >=4)
|
||||
if (str_start_p - *str_p >= 4)
|
||||
{
|
||||
*str_p = str_start_p;
|
||||
if (is_year_sign_negative)
|
||||
{
|
||||
return -parsed_year;
|
||||
}
|
||||
return parsed_year;
|
||||
return is_year_sign_negative ? -parsed_year : parsed_year;
|
||||
}
|
||||
|
||||
return ecma_number_make_nan ();
|
||||
@@ -187,7 +228,7 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
if (!memcmp (month_names_p[i], *str_p, 3))
|
||||
{
|
||||
(*str_p) += 3;
|
||||
return (i+1);
|
||||
return (i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,14 +239,15 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
* Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.9.3.1
|
||||
* ECMA-262 v5, 15.9.4.3
|
||||
* ECMA-262 v11, 20.4.3.4
|
||||
*
|
||||
* @return result of MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))
|
||||
* @return false - if the operation fails
|
||||
* true - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
static bool
|
||||
ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to the Date constructor */
|
||||
uint32_t args_len) /**< number of arguments */
|
||||
uint32_t args_len, /**< number of arguments */
|
||||
ecma_number_t *tv_p) /**< [out] time value */
|
||||
{
|
||||
ecma_number_t date_nums[7] =
|
||||
{
|
||||
@@ -227,32 +269,32 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
{
|
||||
return status;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t prim_value = ecma_number_make_nan ();
|
||||
|
||||
/* 8. */
|
||||
if (!ecma_number_is_nan (date_nums[0]))
|
||||
{
|
||||
/* 8. */
|
||||
ecma_number_t y = ecma_number_trunc (date_nums[0]);
|
||||
/* 9.a */
|
||||
ecma_number_t yi = ecma_number_trunc (date_nums[0]);
|
||||
|
||||
if (y >= 0 && y <= 99)
|
||||
/* 9.b */
|
||||
if (yi >= 0 && yi <= 99)
|
||||
{
|
||||
date_nums[0] = 1900 + y;
|
||||
date_nums[0] = 1900 + yi;
|
||||
}
|
||||
}
|
||||
|
||||
prim_value = ecma_date_make_date (ecma_date_make_day (date_nums[0],
|
||||
date_nums[1],
|
||||
date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3],
|
||||
date_nums[4],
|
||||
date_nums[5],
|
||||
date_nums[6]));
|
||||
|
||||
return ecma_make_number_value (prim_value);
|
||||
/* 10. */
|
||||
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0],
|
||||
date_nums[1],
|
||||
date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3],
|
||||
date_nums[4],
|
||||
date_nums[5],
|
||||
date_nums[6]));
|
||||
return true;
|
||||
} /* ecma_date_construct_helper */
|
||||
|
||||
/**
|
||||
@@ -265,12 +307,13 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
|
||||
* @return the parsed date as ecma_number_t or NaN otherwise
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p,
|
||||
const lit_utf8_byte_t *date_str_end_p)
|
||||
ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date string start */
|
||||
const lit_utf8_byte_t *date_str_end_p) /**< date string end */
|
||||
{
|
||||
/* 1. read year */
|
||||
|
||||
uint32_t year_digits = 4;
|
||||
uint32_t year_limit = 9999;
|
||||
|
||||
bool is_year_sign_negative = false;
|
||||
|
||||
@@ -278,132 +321,136 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p,
|
||||
{
|
||||
is_year_sign_negative = (*date_str_curr_p++ == LIT_CHAR_MINUS);
|
||||
year_digits = 6;
|
||||
year_limit = 999999;
|
||||
}
|
||||
|
||||
ecma_number_t year = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, year_digits,
|
||||
0, (year_digits == 4) ? 9999 : 999999);
|
||||
ecma_number_t year = ecma_date_parse_date_chars (&date_str_curr_p,
|
||||
date_str_end_p,
|
||||
year_digits,
|
||||
ECMA_DATE_LIMIT (0, year_limit));
|
||||
if (is_year_sign_negative)
|
||||
{
|
||||
year = -year;
|
||||
}
|
||||
|
||||
if (!ecma_number_is_nan (year))
|
||||
if (ecma_number_is_nan (year))
|
||||
{
|
||||
ecma_number_t month = ECMA_NUMBER_ONE;
|
||||
ecma_number_t day = ECMA_NUMBER_ONE;
|
||||
ecma_number_t time = ECMA_NUMBER_ZERO;
|
||||
return year;
|
||||
}
|
||||
|
||||
/* 2. read month if any */
|
||||
if (ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_MINUS, LIT_CHAR_SLASH))
|
||||
ecma_number_t month = ECMA_NUMBER_ONE;
|
||||
ecma_number_t day = ECMA_NUMBER_ONE;
|
||||
ecma_number_t time = ECMA_NUMBER_ZERO;
|
||||
|
||||
/* 2. read month if any */
|
||||
if (ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_MINUS, LIT_CHAR_SLASH))
|
||||
{
|
||||
lit_utf8_byte_t separator = *date_str_curr_p++;
|
||||
month = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (1, 12));
|
||||
|
||||
/* 3. read day if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, separator))
|
||||
{
|
||||
lit_utf8_byte_t separator = *date_str_curr_p++;
|
||||
month = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 1, 12);
|
||||
|
||||
/* 3. read day if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, separator))
|
||||
{
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 1, 31);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_utc = true;
|
||||
/* 4. read time if any */
|
||||
if (ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_T, LIT_CHAR_SP))
|
||||
{
|
||||
date_str_curr_p++;
|
||||
|
||||
ecma_number_t hours = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t minutes = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t seconds = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t milliseconds = ECMA_NUMBER_ZERO;
|
||||
|
||||
lit_utf8_size_t remaining_length = lit_utf8_string_length (date_str_curr_p,
|
||||
(lit_utf8_size_t) (date_str_end_p - date_str_curr_p));
|
||||
|
||||
if (remaining_length >= 5)
|
||||
{
|
||||
/* 4.1 read hours and minutes */
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 24);
|
||||
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON))
|
||||
{
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
|
||||
/* 4.2 read seconds if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON))
|
||||
{
|
||||
seconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
|
||||
/* 4.3 read milliseconds if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_DOT))
|
||||
{
|
||||
milliseconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 3, 0, 999);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
minutes = ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
if (hours == 24 && (minutes != 0 || seconds != 0 || milliseconds != 0))
|
||||
{
|
||||
hours = ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
time = ecma_date_make_time (hours, minutes, seconds, milliseconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
time = ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
/* 4.4 read timezone if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_Z)
|
||||
&& !ecma_number_is_nan (time))
|
||||
{
|
||||
time = ecma_date_make_time (hours, minutes, seconds, milliseconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lit_utf8_string_length (date_str_curr_p, (lit_utf8_size_t) (date_str_end_p - date_str_curr_p)) == 6
|
||||
&& ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_MINUS, LIT_CHAR_PLUS))
|
||||
{
|
||||
bool is_timezone_sign_negative = (*date_str_curr_p++ == LIT_CHAR_MINUS);
|
||||
/* read hours and minutes */
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 24);
|
||||
|
||||
if (hours == 24)
|
||||
{
|
||||
hours = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON);
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
ecma_number_t timezone_offset = ecma_date_make_time (hours, minutes, ECMA_NUMBER_ZERO, ECMA_NUMBER_ZERO);
|
||||
time += is_timezone_sign_negative ? timezone_offset : -timezone_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_utc = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (date_str_curr_p >= date_str_end_p)
|
||||
{
|
||||
ecma_number_t date = ecma_date_make_day (year, month - 1, day);
|
||||
|
||||
ecma_number_t result_date = ecma_date_make_date (date, time);
|
||||
if (!is_utc)
|
||||
{
|
||||
result_date = ecma_date_utc (result_date);
|
||||
}
|
||||
|
||||
return result_date;
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (1, 31));
|
||||
}
|
||||
}
|
||||
return ecma_number_make_nan ();
|
||||
|
||||
bool is_utc = true;
|
||||
/* 4. read time if any */
|
||||
if (ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_T, LIT_CHAR_SP))
|
||||
{
|
||||
date_str_curr_p++;
|
||||
|
||||
ecma_number_t hours = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t minutes = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t seconds = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t milliseconds = ECMA_NUMBER_ZERO;
|
||||
|
||||
/* 'HH:mm' must present */
|
||||
if (date_str_end_p - date_str_curr_p < 5)
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
/* 4.1 read hours and minutes */
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 24));
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
|
||||
/* 4.2 read seconds if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON))
|
||||
{
|
||||
seconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
|
||||
/* 4.3 read milliseconds if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_DOT))
|
||||
{
|
||||
milliseconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 3, ECMA_DATE_LIMIT (0, 999));
|
||||
}
|
||||
}
|
||||
|
||||
if (hours == 24 && (minutes != 0 || seconds != 0 || milliseconds != 0))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
time = ecma_date_make_time (hours, minutes, seconds, milliseconds);
|
||||
|
||||
if (ecma_number_is_nan (time))
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
/* 4.4 read timezone if any */
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_Z))
|
||||
{
|
||||
if ((date_str_end_p - date_str_curr_p) == 6
|
||||
&& (*date_str_curr_p == LIT_CHAR_MINUS || *date_str_curr_p == LIT_CHAR_PLUS))
|
||||
{
|
||||
bool is_timezone_sign_negative = (*date_str_curr_p++ == LIT_CHAR_MINUS);
|
||||
/* read hours and minutes */
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 24));
|
||||
|
||||
if (hours == 24)
|
||||
{
|
||||
hours = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_COLON))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
ecma_number_t timezone_offset = ecma_date_make_time (hours, minutes, ECMA_NUMBER_ZERO, ECMA_NUMBER_ZERO);
|
||||
time += is_timezone_sign_negative ? timezone_offset : -timezone_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_utc = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (date_str_curr_p < date_str_end_p)
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
ecma_number_t date = ecma_date_make_day (year, month - 1, day);
|
||||
ecma_number_t result_date = ecma_date_make_date (date, time);
|
||||
|
||||
if (!is_utc)
|
||||
{
|
||||
result_date = ecma_date_utc (result_date);
|
||||
}
|
||||
|
||||
return result_date;
|
||||
} /* ecma_builtin_date_parse_basic */
|
||||
|
||||
/**
|
||||
@@ -440,7 +487,8 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
ecma_number_t day = 0;
|
||||
if (is_toUTCString_format)
|
||||
{
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 31);
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 31));
|
||||
|
||||
if (ecma_number_is_nan (day))
|
||||
{
|
||||
return nan;
|
||||
@@ -452,15 +500,17 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
}
|
||||
|
||||
month = ecma_date_parse_month_name (&date_str_curr_p, date_str_end_p);
|
||||
if (!(int) month)
|
||||
|
||||
if (month == 0)
|
||||
{
|
||||
return nan;
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
month = ecma_date_parse_month_name (&date_str_curr_p, date_str_end_p);
|
||||
if (!(int) month)
|
||||
|
||||
if (month == 0)
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
@@ -470,7 +520,8 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
return nan;
|
||||
}
|
||||
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 31);
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 31));
|
||||
|
||||
if (ecma_number_is_nan (day))
|
||||
{
|
||||
return nan;
|
||||
@@ -483,6 +534,7 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
}
|
||||
|
||||
ecma_number_t year = ecma_date_parse_year (&date_str_curr_p, date_str_end_p);
|
||||
|
||||
if (ecma_number_is_nan (year))
|
||||
{
|
||||
return nan;
|
||||
@@ -493,7 +545,8 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
return nan;
|
||||
}
|
||||
|
||||
ecma_number_t hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 24);
|
||||
ecma_number_t hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 24));
|
||||
|
||||
if (ecma_number_is_nan (hours))
|
||||
{
|
||||
return nan;
|
||||
@@ -504,7 +557,8 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
return nan;
|
||||
}
|
||||
|
||||
ecma_number_t minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
ecma_number_t minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
|
||||
if (ecma_number_is_nan (minutes))
|
||||
{
|
||||
return nan;
|
||||
@@ -515,7 +569,8 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
return nan;
|
||||
}
|
||||
|
||||
ecma_number_t seconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
ecma_number_t seconds = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
|
||||
if (ecma_number_is_nan (seconds))
|
||||
{
|
||||
return nan;
|
||||
@@ -526,63 +581,57 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
return nan;
|
||||
}
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_SP))
|
||||
const char gmt_p[] = " GMT";
|
||||
if (date_str_end_p - date_str_curr_p < 4
|
||||
|| memcmp (date_str_curr_p, gmt_p, 4) != 0)
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_G))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_M))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
if (!ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_UPPERCASE_T))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
date_str_curr_p += 4;
|
||||
|
||||
ecma_number_t time = ecma_date_make_time (hours, minutes, seconds, 0);
|
||||
|
||||
if (!is_toUTCString_format)
|
||||
{
|
||||
bool is_timezone_sign_negative = ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_MINUS);
|
||||
if (!is_timezone_sign_negative && !ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, LIT_CHAR_PLUS))
|
||||
if (!ecma_date_check_two_chars (date_str_curr_p, date_str_end_p, LIT_CHAR_MINUS, LIT_CHAR_PLUS))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 24);
|
||||
bool is_timezone_sign_negative = (*date_str_curr_p++ == LIT_CHAR_MINUS);
|
||||
|
||||
hours = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 24));
|
||||
|
||||
if (ecma_number_is_nan (hours))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
if (hours == 24)
|
||||
{
|
||||
hours = ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 0, 59);
|
||||
minutes = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, ECMA_DATE_LIMIT (0, 59));
|
||||
|
||||
if (ecma_number_is_nan (minutes))
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
|
||||
ecma_number_t timezone_offset = ecma_date_make_time (hours, minutes, ECMA_NUMBER_ZERO, ECMA_NUMBER_ZERO);
|
||||
|
||||
time += is_timezone_sign_negative ? timezone_offset : -timezone_offset;
|
||||
}
|
||||
|
||||
if (date_str_curr_p >= date_str_end_p)
|
||||
if (date_str_curr_p < date_str_end_p)
|
||||
{
|
||||
ecma_number_t date = ecma_date_make_day (year, month - 1, day);
|
||||
return ecma_date_make_date (date, time);
|
||||
return nan;
|
||||
}
|
||||
|
||||
return nan;
|
||||
ecma_number_t date = ecma_date_make_day (year, month - 1, day);
|
||||
return ecma_date_make_date (date, time);
|
||||
} /* ecma_builtin_date_parse_toString_formats */
|
||||
|
||||
/**
|
||||
@@ -594,38 +643,27 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
* ECMA-262 v9, 20.3.4.41 Date.prototype.toString ()
|
||||
* ECMA-262 v9, 20.3.4.43 Date.prototype.toUTCString ()
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
* @return parsed time
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_parse (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t arg) /**< string */
|
||||
static ecma_number_t
|
||||
ecma_builtin_date_parse (ecma_string_t *string_p) /**< string */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
ECMA_STRING_TO_UTF8_STRING (string_p, str_p, str_size);
|
||||
const lit_utf8_byte_t *date_str_curr_p = str_p;
|
||||
const lit_utf8_byte_t *date_str_end_p = str_p + str_size;
|
||||
|
||||
/* Date Time String fromat (ECMA-262 v5, 15.9.1.15) */
|
||||
ecma_string_t *date_str_p = ecma_op_to_string (arg);
|
||||
if (JERRY_UNLIKELY (date_str_p == NULL))
|
||||
/* try to parse date string as ISO string - ECMA-262 v5, 15.9.1.15 */
|
||||
ecma_number_t tv = ecma_builtin_date_parse_basic (date_str_curr_p, date_str_end_p);
|
||||
|
||||
if (ecma_number_is_nan (tv))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
/* try to parse date string in Date.prototype.toString() or toUTCString() format */
|
||||
tv = ecma_builtin_date_parse_toString_formats (date_str_curr_p, date_str_end_p);
|
||||
}
|
||||
|
||||
ECMA_STRING_TO_UTF8_STRING (date_str_p, date_start_p, date_start_size);
|
||||
const lit_utf8_byte_t *date_str_curr_p = date_start_p;
|
||||
const lit_utf8_byte_t *date_str_end_p = date_start_p + date_start_size;
|
||||
ECMA_FINALIZE_UTF8_STRING (str_p, str_size);
|
||||
|
||||
// try to parse date string as ISO string and allow some variants - ECMA-262 v5, 15.9.1.15
|
||||
ecma_number_t ret_value = ecma_builtin_date_parse_basic (date_str_curr_p, date_str_end_p);
|
||||
|
||||
if (ecma_number_is_nan (ret_value))
|
||||
{
|
||||
// try to parse date string in Date.prototype.toString() or toUTCString() format
|
||||
ret_value = ecma_builtin_date_parse_toString_formats (date_str_curr_p, date_str_end_p);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (date_start_p, date_start_size);
|
||||
ecma_deref_ecma_string (date_str_p);
|
||||
return ecma_make_number_value (ecma_date_time_clip (ret_value));
|
||||
return tv;
|
||||
} /* ecma_builtin_date_parse */
|
||||
|
||||
/**
|
||||
@@ -638,12 +676,9 @@ ecma_builtin_date_parse (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_utc (ecma_value_t this_arg, /**< this argument */
|
||||
const ecma_value_t args[], /**< arguments list */
|
||||
ecma_builtin_date_utc (const ecma_value_t args[], /**< arguments list */
|
||||
uint32_t args_number) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
const uint32_t required_args_number = 1;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
@@ -652,25 +687,17 @@ ecma_builtin_date_utc (ecma_value_t this_arg, /**< this argument */
|
||||
|
||||
if (args_number < required_args_number)
|
||||
{
|
||||
/* Note:
|
||||
* When the UTC function is called with fewer than two arguments,
|
||||
* the behaviour is implementation-dependent, so just return NaN.
|
||||
*/
|
||||
return ecma_make_number_value (ecma_number_make_nan ());
|
||||
}
|
||||
|
||||
ecma_value_t time_value = ecma_date_construct_helper (args, args_number);
|
||||
ecma_number_t tv;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (time_value))
|
||||
if (!ecma_date_construct_helper (args, args_number, &tv))
|
||||
{
|
||||
return time_value;
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_number_t time = ecma_get_number_from_value (time_value);
|
||||
|
||||
ecma_free_value (time_value);
|
||||
|
||||
return ecma_make_number_value (ecma_date_time_clip (time));
|
||||
return ecma_make_number_value ((ecma_number_t) ecma_date_time_clip (tv));
|
||||
} /* ecma_builtin_date_utc */
|
||||
|
||||
/**
|
||||
@@ -685,20 +712,49 @@ ecma_builtin_date_now_helper (void)
|
||||
} /* ecma_builtin_date_now_helper */
|
||||
|
||||
/**
|
||||
* The Date object's 'now' routine
|
||||
* Construct a date object with the given [[DateValue]]
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.9.4.4
|
||||
* Note: New target must be a valid object
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
* @return ECMA_VALUE_ERROR - if the operation fails
|
||||
* constructed date object - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_now (ecma_value_t this_arg) /**< this argument */
|
||||
ecma_builtin_date_create (ecma_number_t tv)
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
return ecma_make_number_value (ecma_builtin_date_now_helper ());
|
||||
} /* ecma_builtin_date_now */
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL);
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p, sizeof (ecma_date_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
ecma_date_object_t *date_object_p = (ecma_date_object_t *) obj_p;
|
||||
date_object_p->header.u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
date_object_p->header.u.class_prop.u.tza = 0;
|
||||
date_object_p->header.u.class_prop.extra_info = ECMA_DATE_TZA_NONE;
|
||||
date_object_p->date_value = tv;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_number_t *date_value_p = ecma_alloc_number ();
|
||||
*date_value_p = tv;
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.date, date_value_p);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_builtin_date_create */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Date object
|
||||
@@ -715,9 +771,7 @@ ecma_builtin_date_dispatch_call (const ecma_value_t *arguments_list_p, /**< argu
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
JERRY_UNUSED (arguments_list_len);
|
||||
|
||||
ecma_number_t now_val_num = ecma_builtin_date_now_helper ();
|
||||
|
||||
return ecma_date_value_to_string (now_val_num);
|
||||
return ecma_date_value_to_string (ecma_builtin_date_now_helper ());
|
||||
} /* ecma_builtin_date_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -733,137 +787,125 @@ ecma_value_t
|
||||
ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p));
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
#endif /* (JERRY_ESNEXT */
|
||||
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_UNDEFINED;
|
||||
|
||||
ecma_number_t prim_value_num = ECMA_NUMBER_ZERO;
|
||||
|
||||
/* 20.4.2.3 */
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
prim_value_num = ecma_builtin_date_now_helper ();
|
||||
return ecma_builtin_date_create (ecma_builtin_date_now_helper ());
|
||||
}
|
||||
|
||||
ecma_number_t tv;
|
||||
/* 20.4.2.2 */
|
||||
else if (arguments_list_len == 1)
|
||||
if (arguments_list_len == 1)
|
||||
{
|
||||
ecma_value_t argument = arguments_list_p[0];
|
||||
ecma_object_t *arg_obj = NULL;
|
||||
|
||||
/* 4.a */
|
||||
if (ecma_is_value_object (argument))
|
||||
if (ecma_is_value_object (argument)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (argument), LIT_MAGIC_STRING_DATE_UL))
|
||||
{
|
||||
arg_obj = ecma_get_object_from_value (argument);
|
||||
}
|
||||
|
||||
if (arg_obj && ecma_object_class_is (arg_obj, LIT_MAGIC_STRING_DATE_UL))
|
||||
{
|
||||
ecma_extended_object_t *arg_ext_object_p = (ecma_extended_object_t *) arg_obj;
|
||||
prim_value_num = *ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, arg_ext_object_p->u.class_prop.u.value);
|
||||
#if JERRY_ESNEXT
|
||||
tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_extended_object_t *arg_ext_object_p = (ecma_extended_object_t *) ecma_get_object_from_value (argument);
|
||||
tv = *ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, arg_ext_object_p->u.class_prop.u.date);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
return ecma_builtin_date_create (tv);
|
||||
}
|
||||
/* 4.b */
|
||||
ecma_value_t primitive = ecma_op_to_primitive (argument, ECMA_PREFERRED_TYPE_NO);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (primitive))
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
|
||||
if (ecma_is_value_string (primitive))
|
||||
{
|
||||
ecma_string_t *prim_str_p = ecma_get_string_from_value (primitive);
|
||||
tv = ecma_builtin_date_parse (prim_str_p);
|
||||
ecma_deref_ecma_string (prim_str_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t prim_comp_value = ecma_op_to_primitive (argument, ECMA_PREFERRED_TYPE_NO);
|
||||
ecma_value_t prim_value = ecma_op_to_number (primitive, &tv);
|
||||
ecma_free_value (primitive);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (prim_comp_value))
|
||||
if (ECMA_IS_VALUE_ERROR (prim_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
return prim_comp_value;
|
||||
return prim_value;
|
||||
}
|
||||
|
||||
if (ecma_is_value_string (prim_comp_value))
|
||||
{
|
||||
ecma_value_t parse_res_value = ecma_builtin_date_parse (ecma_make_object_value (obj_p), prim_comp_value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (parse_res_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
ecma_free_value (prim_comp_value);
|
||||
return parse_res_value;
|
||||
}
|
||||
|
||||
prim_value_num = ecma_get_number_from_value (parse_res_value);
|
||||
|
||||
ecma_free_value (parse_res_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t arg;
|
||||
ecma_value_t prim_value = ecma_op_to_number (prim_comp_value, &arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (prim_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
ecma_free_value (prim_comp_value);
|
||||
return prim_value;
|
||||
}
|
||||
|
||||
prim_value_num = ecma_date_time_clip (arg);
|
||||
|
||||
}
|
||||
|
||||
ecma_free_value (prim_comp_value);
|
||||
}
|
||||
}
|
||||
/* 20.4.2.1 */
|
||||
else if (ecma_date_construct_helper (arguments_list_p, arguments_list_len, &tv))
|
||||
{
|
||||
tv = ecma_date_utc (tv);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t time_value = ecma_date_construct_helper (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (time_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
return time_value;
|
||||
}
|
||||
|
||||
ecma_number_t time = ecma_get_number_from_value (time_value);
|
||||
prim_value_num = ecma_date_time_clip (ecma_date_utc (time));
|
||||
|
||||
ecma_free_value (time_value);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (!ecma_number_is_nan (prim_value_num) && ecma_number_is_infinity (prim_value_num))
|
||||
{
|
||||
prim_value_num = ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
|
||||
ecma_number_t *date_num_p = ecma_alloc_number ();
|
||||
*date_num_p = prim_value_num;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, date_num_p);
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
return ecma_builtin_date_create (ecma_date_time_clip (tv));
|
||||
} /* ecma_builtin_date_dispatch_construct */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_date_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_DATE_ROUTINE_NOW:
|
||||
{
|
||||
return ecma_make_number_value (ecma_builtin_date_now_helper ());
|
||||
}
|
||||
case ECMA_DATE_ROUTINE_UTC:
|
||||
{
|
||||
return ecma_builtin_date_utc (arguments_list_p, arguments_number);
|
||||
}
|
||||
case ECMA_DATE_ROUTINE_PARSE:
|
||||
{
|
||||
if (arguments_number < 1)
|
||||
{
|
||||
return ecma_make_number_value (ecma_number_make_nan ());
|
||||
}
|
||||
|
||||
ecma_string_t *str_p = ecma_op_to_string (arguments_list_p[0]);
|
||||
|
||||
if (JERRY_UNLIKELY (str_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_make_number_value (ecma_date_time_clip (ecma_builtin_date_parse (str_p)));
|
||||
ecma_deref_ecma_string (str_p);
|
||||
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_date_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#undef BREAK_IF_FALSE
|
||||
#undef BREAK_IF_NAN
|
||||
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
|
||||
Reference in New Issue
Block a user