|
|
@ -1248,145 +1248,308 @@ impl Date { |
|
|
|
|
|
|
|
|
|
|
|
let prototype = Value::new_object(Some(global)); |
|
|
|
let prototype = Value::new_object(Some(global)); |
|
|
|
|
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_date), "getDate", &prototype, 0); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn(getter_method!(get_day), "getDay", &prototype, 0); |
|
|
|
getter_method!(get_date), |
|
|
|
make_builtin_fn(getter_method!(get_full_year), "getFullYear", &prototype, 0); |
|
|
|
"getDate", |
|
|
|
make_builtin_fn(getter_method!(get_hours), "getHours", &prototype, 0); |
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_day), |
|
|
|
|
|
|
|
"getDay", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_full_year), |
|
|
|
|
|
|
|
"getFullYear", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_hours), |
|
|
|
|
|
|
|
"getHours", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(get_milliseconds), |
|
|
|
getter_method!(get_milliseconds), |
|
|
|
"getMilliseconds", |
|
|
|
"getMilliseconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_minutes), |
|
|
|
|
|
|
|
"getMinutes", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_month), |
|
|
|
|
|
|
|
"getMonth", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_seconds), |
|
|
|
|
|
|
|
"getSeconds", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_time), |
|
|
|
|
|
|
|
"getTime", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_year), |
|
|
|
|
|
|
|
"getYear", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(get_minutes), "getMinutes", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_month), "getMonth", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_seconds), "getSeconds", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_time), "getTime", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_year), "getYear", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(Self::get_timezone_offset), |
|
|
|
getter_method!(Self::get_timezone_offset), |
|
|
|
"getTimezoneOffset", |
|
|
|
"getTimezoneOffset", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_utc_date), |
|
|
|
|
|
|
|
"getUTCDate", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_utc_day), |
|
|
|
|
|
|
|
"getUTCDay", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(get_utc_date), "getUTCDate", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(get_utc_day), "getUTCDay", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(get_utc_full_year), |
|
|
|
getter_method!(get_utc_full_year), |
|
|
|
"getUTCFullYear", |
|
|
|
"getUTCFullYear", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_utc_hours), |
|
|
|
|
|
|
|
"getUTCHours", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(get_utc_hours), "getUTCHours", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(get_utc_milliseconds), |
|
|
|
getter_method!(get_utc_milliseconds), |
|
|
|
"getUTCMilliseconds", |
|
|
|
"getUTCMilliseconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(get_utc_minutes), |
|
|
|
getter_method!(get_utc_minutes), |
|
|
|
"getUTCMinutes", |
|
|
|
"getUTCMinutes", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(get_utc_month), |
|
|
|
|
|
|
|
"getUTCMonth", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(get_utc_month), "getUTCMonth", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(get_utc_seconds), |
|
|
|
getter_method!(get_utc_seconds), |
|
|
|
"getUTCSeconds", |
|
|
|
"getUTCSeconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
setter_method!(set_date(0)), |
|
|
|
|
|
|
|
"setDate", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(setter_method!(set_date(0)), "setDate", &prototype, 1); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_full_year(0, 1, 2)), |
|
|
|
setter_method!(set_full_year(0, 1, 2)), |
|
|
|
"setFullYear", |
|
|
|
"setFullYear", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_hours(0, 1, 2, 3)), |
|
|
|
setter_method!(set_hours(0, 1, 2, 3)), |
|
|
|
"setHours", |
|
|
|
"setHours", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_milliseconds(0)), |
|
|
|
setter_method!(set_milliseconds(0)), |
|
|
|
"setMilliseconds", |
|
|
|
"setMilliseconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_minutes(0, 1, 2)), |
|
|
|
setter_method!(set_minutes(0, 1, 2)), |
|
|
|
"setMinutes", |
|
|
|
"setMinutes", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
setter_method!(set_month(0, 1)), |
|
|
|
|
|
|
|
"setMonth", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(setter_method!(set_month(0, 1)), "setMonth", &prototype, 1); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_seconds(0, 1)), |
|
|
|
setter_method!(set_seconds(0, 1)), |
|
|
|
"setSeconds", |
|
|
|
"setSeconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
setter_method!(set_year(0, 1, 2)), |
|
|
|
|
|
|
|
"setYear", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
setter_method!(set_time(0)), |
|
|
|
|
|
|
|
"setTime", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
setter_method!(set_utc_date(0)), |
|
|
|
|
|
|
|
"setUTCDate", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(setter_method!(set_year(0, 1, 2)), "setYear", &prototype, 1); |
|
|
|
|
|
|
|
make_builtin_fn(setter_method!(set_time(0)), "setTime", &prototype, 1); |
|
|
|
|
|
|
|
make_builtin_fn(setter_method!(set_utc_date(0)), "setUTCDate", &prototype, 1); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_full_year(0, 1, 2)), |
|
|
|
setter_method!(set_utc_full_year(0, 1, 2)), |
|
|
|
"setUTCFullYear", |
|
|
|
"setUTCFullYear", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_hours(0, 1, 2, 3)), |
|
|
|
setter_method!(set_utc_hours(0, 1, 2, 3)), |
|
|
|
"setUTCHours", |
|
|
|
"setUTCHours", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_milliseconds(0)), |
|
|
|
setter_method!(set_utc_milliseconds(0)), |
|
|
|
"setUTCMilliseconds", |
|
|
|
"setUTCMilliseconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_minutes(0, 1, 2)), |
|
|
|
setter_method!(set_utc_minutes(0, 1, 2)), |
|
|
|
"setUTCMinutes", |
|
|
|
"setUTCMinutes", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_month(0, 1)), |
|
|
|
setter_method!(set_utc_month(0, 1)), |
|
|
|
"setUTCMonth", |
|
|
|
"setUTCMonth", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
setter_method!(set_utc_seconds(0, 1)), |
|
|
|
setter_method!(set_utc_seconds(0, 1)), |
|
|
|
"setUTCSeconds", |
|
|
|
"setUTCSeconds", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
1, |
|
|
|
1, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(to_date_string), |
|
|
|
getter_method!(to_date_string), |
|
|
|
"toDateString", |
|
|
|
"toDateString", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(to_gmt_string), |
|
|
|
|
|
|
|
"toGMTString", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(to_iso_string), |
|
|
|
|
|
|
|
"toISOString", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(to_json), |
|
|
|
|
|
|
|
"toJSON", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(to_gmt_string), "toGMTString", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(to_iso_string), "toISOString", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(to_json), "toJSON", &prototype, 0); |
|
|
|
|
|
|
|
// Locale strings
|
|
|
|
// Locale strings
|
|
|
|
make_builtin_fn(getter_method!(to_string), "toString", &prototype, 0); |
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(to_string), |
|
|
|
|
|
|
|
"toString", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
make_builtin_fn( |
|
|
|
make_builtin_fn( |
|
|
|
getter_method!(to_time_string), |
|
|
|
getter_method!(to_time_string), |
|
|
|
"toTimeString", |
|
|
|
"toTimeString", |
|
|
|
&prototype, |
|
|
|
&prototype, |
|
|
|
0, |
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(to_utc_string), |
|
|
|
|
|
|
|
"toUTCString", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
make_builtin_fn( |
|
|
|
|
|
|
|
getter_method!(value_of), |
|
|
|
|
|
|
|
"valueOf", |
|
|
|
|
|
|
|
&prototype, |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
interpreter, |
|
|
|
); |
|
|
|
); |
|
|
|
make_builtin_fn(getter_method!(to_utc_string), "toUTCString", &prototype, 0); |
|
|
|
|
|
|
|
make_builtin_fn(getter_method!(value_of), "valueOf", &prototype, 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let date_time_object = make_constructor_fn( |
|
|
|
let date_time_object = make_constructor_fn( |
|
|
|
Self::NAME, |
|
|
|
Self::NAME, |
|
|
@ -1398,9 +1561,9 @@ impl Date { |
|
|
|
true, |
|
|
|
true, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
make_builtin_fn(Self::now, "now", &date_time_object, 0); |
|
|
|
make_builtin_fn(Self::now, "now", &date_time_object, 0, interpreter); |
|
|
|
make_builtin_fn(Self::parse, "parse", &date_time_object, 1); |
|
|
|
make_builtin_fn(Self::parse, "parse", &date_time_object, 1, interpreter); |
|
|
|
make_builtin_fn(Self::utc, "UTC", &date_time_object, 7); |
|
|
|
make_builtin_fn(Self::utc, "UTC", &date_time_object, 7, interpreter); |
|
|
|
(Self::NAME, date_time_object) |
|
|
|
(Self::NAME, date_time_object) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|