|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
#include <AK/TypeCasts.h>
|
|
#include <AK/TypeCasts.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
+#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
|
#include <LibJS/Runtime/Temporal/Calendar.h>
|
|
#include <LibJS/Runtime/Temporal/Calendar.h>
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDay.h>
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDay.h>
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDayPrototype.h>
|
|
#include <LibJS/Runtime/Temporal/PlainMonthDayPrototype.h>
|
|
@@ -32,6 +33,7 @@ void PlainMonthDayPrototype::initialize(GlobalObject& global_object)
|
|
define_native_accessor(vm.names.day, day_getter, {}, Attribute::Configurable);
|
|
define_native_accessor(vm.names.day, day_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
|
+ define_native_function(vm.names.toString, to_string, 0, attr);
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
}
|
|
}
|
|
@@ -94,6 +96,33 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::day_getter)
|
|
return Value(calendar_day(global_object, calendar, *month_day));
|
|
return Value(calendar_day(global_object, calendar, *month_day));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 10.3.8 Temporal.PlainMonthDay.prototype.toString ( [ options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tostring
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string)
|
|
|
|
+{
|
|
|
|
+ // 1. Let monthDay be the this value.
|
|
|
|
+ // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
|
|
|
+ auto* month_day = typed_this(global_object);
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ // 3. Set options to ? GetOptionsObject(options).
|
|
|
|
+ auto* options = get_options_object(global_object, vm.argument(0));
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ // 4. Let showCalendar be ? ToShowCalendarOption(options).
|
|
|
|
+ auto show_calendar = to_show_calendar_option(global_object, *options);
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ // 5. Return ? TemporalMonthDayToString(monthDay, showCalendar).
|
|
|
|
+ auto string = temporal_month_day_to_string(global_object, *month_day, *show_calendar);
|
|
|
|
+ if (vm.exception())
|
|
|
|
+ return {};
|
|
|
|
+
|
|
|
|
+ return js_string(vm, *string);
|
|
|
|
+}
|
|
|
|
+
|
|
// 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof
|
|
// 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::value_of)
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::value_of)
|
|
{
|
|
{
|