|
@@ -64,6 +64,7 @@ void PlainDateTimePrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_function(vm.names.subtract, subtract, 1, attr);
|
|
|
define_native_function(vm.names.equals, equals, 1, attr);
|
|
|
define_native_function(vm.names.toString, to_string, 0, attr);
|
|
|
+ define_native_function(vm.names.toLocaleString, to_locale_string, 0, attr);
|
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
|
define_native_function(vm.names.toZonedDateTime, to_zoned_date_time, 1, attr);
|
|
|
define_native_function(vm.names.toPlainDate, to_plain_date, 0, attr);
|
|
@@ -496,6 +497,18 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_string)
|
|
|
return js_string(vm, TRY(temporal_date_time_to_string(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, &date_time->calendar(), precision.precision, show_calendar)));
|
|
|
}
|
|
|
|
|
|
+// 5.3.33 Temporal.PlainDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tolocalestring
|
|
|
+// NOTE: This is the minimum toLocaleString implementation for engines without ECMA-402.
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_locale_string)
|
|
|
+{
|
|
|
+ // 1. Let dateTime be the this value.
|
|
|
+ // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
|
|
+ auto* date_time = TRY(typed_this_object(global_object));
|
|
|
+
|
|
|
+ // 3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto").
|
|
|
+ return js_string(vm, TRY(temporal_date_time_to_string(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv)));
|
|
|
+}
|
|
|
+
|
|
|
// 5.3.35 Temporal.PlainDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.valueof
|
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::value_of)
|
|
|
{
|