3838
3939namespace JSC {
4040
41+ static JSC_DECLARE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToPlainDate);
4142static JSC_DECLARE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToString);
4243static JSC_DECLARE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToJSON);
4344static JSC_DECLARE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToLocaleString);
@@ -63,6 +64,7 @@ const ClassInfo TemporalPlainYearMonthPrototype::s_info = { "Temporal.PlainYearM
6364
6465/* Source for TemporalPlainYearMonthPrototype.lut.h
6566@begin plainYearMonthPrototypeTable
67+ toPlainDate temporalPlainYearMonthPrototypeFuncToPlainDate DontEnum|Function 1
6668 toString temporalPlainYearMonthPrototypeFuncToString DontEnum|Function 0
6769 toJSON temporalPlainYearMonthPrototypeFuncToJSON DontEnum|Function 0
6870 toLocaleString temporalPlainYearMonthPrototypeFuncToLocaleString DontEnum|Function 0
@@ -104,19 +106,6 @@ void TemporalPlainYearMonthPrototype::finishCreation(VM& vm, JSGlobalObject*)
104106 JSC_TO_STRING_TAG_WITHOUT_TRANSITION ();
105107}
106108
107- // https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tostring
108- JSC_DEFINE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToString, (JSGlobalObject* globalObject, CallFrame* callFrame))
109- {
110- VM& vm = globalObject->vm ();
111- auto scope = DECLARE_THROW_SCOPE (vm);
112-
113- auto * yearMonth = jsDynamicCast<TemporalPlainYearMonth*>(callFrame->thisValue ());
114- if (!yearMonth) [[unlikely]]
115- return throwVMTypeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toString called on value that's not a PlainYearMonth" _s);
116-
117- RELEASE_AND_RETURN (scope, JSValue::encode (jsString (vm, yearMonth->toString (globalObject, callFrame->argument (0 )))));
118- }
119-
120109// https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.with
121110JSC_DEFINE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncWith, (JSGlobalObject* globalObject, CallFrame* callFrame))
122111{
@@ -156,6 +145,53 @@ JSC_DEFINE_HOST_FUNCTION(temporalPlainYearMonthPrototypeFuncEquals, (JSGlobalObj
156145 return JSValue::encode (jsBoolean (true ));
157146}
158147
148+ // https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.toplaindatetime
149+ JSC_DEFINE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToPlainDate, (JSGlobalObject* globalObject, CallFrame* callFrame))
150+ {
151+ VM& vm = globalObject->vm ();
152+ auto scope = DECLARE_THROW_SCOPE (vm);
153+
154+ auto * yearMonth = jsDynamicCast<TemporalPlainYearMonth*>(callFrame->thisValue ());
155+ if (!yearMonth) [[unlikely]]
156+ return throwVMTypeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toPlainDate called on value that's not a PlainYearMonth" _s);
157+
158+ JSValue itemValue = callFrame->argument (0 );
159+ if (!itemValue.isObject ()) [[unlikely]]
160+ return throwVMTypeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toPlainDate: item is not an object" _s);
161+
162+ auto thisYear = yearMonth->year ();
163+ auto thisMonth = yearMonth->month ();
164+ auto itemDay = TemporalPlainDate::toDay (globalObject, asObject (itemValue));
165+ RETURN_IF_EXCEPTION (scope, { });
166+
167+ if (!itemDay) [[unlikely]] {
168+ throwTypeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toPlainDate: item does not have a day field" _s);
169+ return { };
170+ }
171+
172+ auto plainDateOptional =
173+ TemporalDuration::regulateISODate (thisYear, thisMonth, itemDay.value (), TemporalOverflow::Constrain);
174+ if (!plainDateOptional) [[unlikely]] {
175+ throwRangeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toPlainDate: date is invalid" _s);
176+ return { };
177+ }
178+
179+ RELEASE_AND_RETURN (scope, JSValue::encode (TemporalPlainDate::tryCreateIfValid (globalObject, globalObject->plainDateStructure (), WTFMove (plainDateOptional.value ()))));
180+ }
181+
182+ // https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tostring
183+ JSC_DEFINE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToString, (JSGlobalObject* globalObject, CallFrame* callFrame))
184+ {
185+ VM& vm = globalObject->vm ();
186+ auto scope = DECLARE_THROW_SCOPE (vm);
187+
188+ auto * yearMonth = jsDynamicCast<TemporalPlainYearMonth*>(callFrame->thisValue ());
189+ if (!yearMonth) [[unlikely]]
190+ return throwVMTypeError (globalObject, scope, " Temporal.PlainYearMonth.prototype.toString called on value that's not a PlainYearMonth" _s);
191+
192+ RELEASE_AND_RETURN (scope, JSValue::encode (jsString (vm, yearMonth->toString (globalObject, callFrame->argument (0 )))));
193+ }
194+
159195// https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tojson
160196JSC_DEFINE_HOST_FUNCTION (temporalPlainYearMonthPrototypeFuncToJSON, (JSGlobalObject* globalObject, CallFrame* callFrame))
161197{
0 commit comments