mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
LibJS: Rename DateFromFields to CalendarDateFromFields, etc
This is an editorial change in the Temporal spec.
See: fd27b54
This commit is contained in:
parent
a7f702a021
commit
2499911898
11 changed files with 71 additions and 80 deletions
|
@ -458,69 +458,60 @@ ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&
|
||||||
return to_temporal_calendar_with_iso_default(global_object, calendar_like);
|
return to_temporal_calendar_with_iso_default(global_object, calendar_like);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12.1.24 DateFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-datefromfields
|
// 12.1.24 CalendarDateFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-calendardatefromfields
|
||||||
ThrowCompletionOr<PlainDate*> date_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
ThrowCompletionOr<PlainDate*> calendar_date_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
// 1. Assert: Type(calendar) is Object.
|
// 1. If options is not present, set options to undefined.
|
||||||
// 2. Assert: Type(fields) is Object.
|
|
||||||
// 3. If options is not present, set options to undefined.
|
|
||||||
// 4. Assert: Type(options) is Object or Undefined.
|
|
||||||
|
|
||||||
// 5. Let date be ? Invoke(calendar, "dateFromFields", « fields, options »).
|
// 2. Let date be ? Invoke(calendar, "dateFromFields", « fields, options »).
|
||||||
auto date = TRY(Value(&calendar).invoke(global_object, vm.names.dateFromFields, &fields, options ?: js_undefined()));
|
auto date = TRY(Value(&calendar).invoke(global_object, vm.names.dateFromFields, &fields, options ?: js_undefined()));
|
||||||
|
|
||||||
// 6. Perform ? RequireInternalSlot(date, [[InitializedTemporalDate]]).
|
// 3. Perform ? RequireInternalSlot(date, [[InitializedTemporalDate]]).
|
||||||
auto* date_object = TRY(date.to_object(global_object));
|
auto* date_object = TRY(date.to_object(global_object));
|
||||||
if (!is<PlainDate>(date_object))
|
if (!is<PlainDate>(date_object))
|
||||||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainDate");
|
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainDate");
|
||||||
|
|
||||||
// 7. Return date.
|
// 4. Return date.
|
||||||
return static_cast<PlainDate*>(date_object);
|
return static_cast<PlainDate*>(date_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12.1.25 YearMonthFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-yearmonthfromfields
|
// 12.1.25 CalendarYearMonthFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-calendaryearmonthfromfields
|
||||||
ThrowCompletionOr<PlainYearMonth*> year_month_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
ThrowCompletionOr<PlainYearMonth*> calendar_year_month_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
// 1. Assert: Type(calendar) is Object.
|
// 1. If options is not present, set options to undefined.
|
||||||
// 2. Assert: Type(fields) is Object.
|
|
||||||
// 3. If options is not present, set options to undefined.
|
|
||||||
// 4. Assert: Type(options) is Object or Undefined.
|
|
||||||
|
|
||||||
// 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »).
|
// 2. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »).
|
||||||
auto year_month = TRY(Value(&calendar).invoke(global_object, vm.names.yearMonthFromFields, &fields, options ?: js_undefined()));
|
auto year_month = TRY(Value(&calendar).invoke(global_object, vm.names.yearMonthFromFields, &fields, options ?: js_undefined()));
|
||||||
|
|
||||||
// 6. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
// 3. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||||
auto* year_month_object = TRY(year_month.to_object(global_object));
|
auto* year_month_object = TRY(year_month.to_object(global_object));
|
||||||
if (!is<PlainYearMonth>(year_month_object))
|
if (!is<PlainYearMonth>(year_month_object))
|
||||||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainYearMonth");
|
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainYearMonth");
|
||||||
|
|
||||||
// 7. Return yearMonth.
|
// 4. Return yearMonth.
|
||||||
return static_cast<PlainYearMonth*>(year_month_object);
|
return static_cast<PlainYearMonth*>(year_month_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12.1.26 MonthDayFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-monthdayfromfields
|
// 12.1.26 CalendarMonthDayFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmonthdayfromfields
|
||||||
ThrowCompletionOr<PlainMonthDay*> month_day_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
// 1. Assert: Type(calendar) is Object.
|
// 1. If options is not present, set options to undefined.
|
||||||
// 2. Assert: Type(fields) is Object.
|
|
||||||
// 3. If options is not present, set options to undefined.
|
|
||||||
// 4. Assert: Type(options) is Object or Undefined.
|
|
||||||
|
|
||||||
// 5. Let monthDay be ? Invoke(calendar, "monthDayFromFields", « fields, options »).
|
// 2. Let monthDay be ? Invoke(calendar, "monthDayFromFields", « fields, options »).
|
||||||
auto month_day = TRY(Value(&calendar).invoke(global_object, vm.names.monthDayFromFields, &fields, options ?: js_undefined()));
|
auto month_day = TRY(Value(&calendar).invoke(global_object, vm.names.monthDayFromFields, &fields, options ?: js_undefined()));
|
||||||
|
|
||||||
// 6. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
// 3. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||||
auto* month_day_object = TRY(month_day.to_object(global_object));
|
auto* month_day_object = TRY(month_day.to_object(global_object));
|
||||||
if (!is<PlainMonthDay>(month_day_object))
|
if (!is<PlainMonthDay>(month_day_object))
|
||||||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainMonthDay");
|
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainMonthDay");
|
||||||
|
|
||||||
// 7. Return monthDay.
|
// 4. Return monthDay.
|
||||||
return static_cast<PlainMonthDay*>(month_day_object);
|
return static_cast<PlainMonthDay*>(month_day_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ ThrowCompletionOr<Value> calendar_era_year(GlobalObject&, Object& calendar, Obje
|
||||||
ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject&, Value);
|
ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject&, Value);
|
||||||
ThrowCompletionOr<Object*> to_temporal_calendar_with_iso_default(GlobalObject&, Value);
|
ThrowCompletionOr<Object*> to_temporal_calendar_with_iso_default(GlobalObject&, Value);
|
||||||
ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&, Object&);
|
ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&, Object&);
|
||||||
ThrowCompletionOr<PlainDate*> date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
ThrowCompletionOr<PlainDate*> calendar_date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||||
ThrowCompletionOr<PlainYearMonth*> year_month_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
ThrowCompletionOr<PlainYearMonth*> calendar_year_month_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||||
ThrowCompletionOr<PlainMonthDay*> month_day_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
|
||||||
String format_calendar_annotation(StringView id, StringView show_calendar);
|
String format_calendar_annotation(StringView id, StringView show_calendar);
|
||||||
ThrowCompletionOr<bool> calendar_equals(GlobalObject&, Object& one, Object& two);
|
ThrowCompletionOr<bool> calendar_equals(GlobalObject&, Object& one, Object& two);
|
||||||
ThrowCompletionOr<Object*> consolidate_calendars(GlobalObject&, Object& one, Object& two);
|
ThrowCompletionOr<Object*> consolidate_calendars(GlobalObject&, Object& one, Object& two);
|
||||||
|
|
|
@ -115,8 +115,8 @@ ThrowCompletionOr<PlainDate*> to_temporal_date(GlobalObject& global_object, Valu
|
||||||
// f. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
|
// f. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, item_object, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, item_object, field_names, {}));
|
||||||
|
|
||||||
// g. Return ? DateFromFields(calendar, fields, options).
|
// g. Return ? CalendarDateFromFields(calendar, fields, options).
|
||||||
return date_from_fields(global_object, *calendar, *fields, options);
|
return calendar_date_from_fields(global_object, *calendar, *fields, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? ToTemporalOverflow(options).
|
// 4. Perform ? ToTemporalOverflow(options).
|
||||||
|
|
|
@ -292,8 +292,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_year_month)
|
||||||
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date, field_names, {}));
|
||||||
|
|
||||||
// 6. Return ? YearMonthFromFields(calendar, fields).
|
// 6. Return ? CalendarYearMonthFromFields(calendar, fields).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.3.17 Temporal.PlainDate.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.toplainmonthday
|
// 3.3.17 Temporal.PlainDate.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.toplainmonthday
|
||||||
|
@ -312,8 +312,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_month_day)
|
||||||
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date, field_names, {}));
|
||||||
|
|
||||||
// 6. Return ? MonthDayFromFields(calendar, fields).
|
// 6. Return ? CalendarMonthDayFromFields(calendar, fields).
|
||||||
return TRY(month_day_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_month_day_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.3.18 Temporal.PlainDate.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.getisofields
|
// 3.3.18 Temporal.PlainDate.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.getisofields
|
||||||
|
@ -418,8 +418,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
|
||||||
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
||||||
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
||||||
|
|
||||||
// 12. Return ? DateFromFields(calendar, fields, options).
|
// 12. Return ? CalendarDateFromFields(calendar, fields, options).
|
||||||
return TRY(date_from_fields(global_object, calendar, *fields, options));
|
return TRY(calendar_date_from_fields(global_object, calendar, *fields, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.3.22 Temporal.PlainDate.prototype.withCalendar ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.withcalendar
|
// 3.3.22 Temporal.PlainDate.prototype.withCalendar ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.withcalendar
|
||||||
|
|
|
@ -110,8 +110,8 @@ ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(GlobalObject&
|
||||||
// 2. Let overflow be ? ToTemporalOverflow(options).
|
// 2. Let overflow be ? ToTemporalOverflow(options).
|
||||||
auto overflow = TRY(to_temporal_overflow(global_object, &options));
|
auto overflow = TRY(to_temporal_overflow(global_object, &options));
|
||||||
|
|
||||||
// 3. Let temporalDate be ? DateFromFields(calendar, fields, options).
|
// 3. Let temporalDate be ? CalendarDateFromFields(calendar, fields, options).
|
||||||
auto* temporal_date = TRY(date_from_fields(global_object, calendar, fields, &options));
|
auto* temporal_date = TRY(calendar_date_from_fields(global_object, calendar, fields, &options));
|
||||||
|
|
||||||
// 4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
|
// 4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
|
||||||
auto time_result = TRY(regulate_time(global_object, unregulated_time_result.hour, unregulated_time_result.minute, unregulated_time_result.second, unregulated_time_result.millisecond, unregulated_time_result.microsecond, unregulated_time_result.nanosecond, overflow));
|
auto time_result = TRY(regulate_time(global_object, unregulated_time_result.hour, unregulated_time_result.minute, unregulated_time_result.second, unregulated_time_result.millisecond, unregulated_time_result.microsecond, unregulated_time_result.nanosecond, overflow));
|
||||||
|
|
|
@ -802,8 +802,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_year_month)
|
||||||
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *date_time, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *date_time, field_names, {}));
|
||||||
|
|
||||||
// 6. Return ? YearMonthFromFields(calendar, fields).
|
// 6. Return ? CalendarYearMonthFromFields(calendar, fields).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.3.39 Temporal.PlainDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.toplainmonthday
|
// 5.3.39 Temporal.PlainDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.toplainmonthday
|
||||||
|
@ -822,8 +822,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_month_day)
|
||||||
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *date_time, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *date_time, field_names, {}));
|
||||||
|
|
||||||
// 6. Return ? MonthDayFromFields(calendar, fields).
|
// 6. Return ? CalendarMonthDayFromFields(calendar, fields).
|
||||||
return TRY(month_day_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_month_day_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.3.40 Temporal.PlainDateTime.prototype.toPlainTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.toplaintime
|
// 5.3.40 Temporal.PlainDateTime.prototype.toPlainTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.toplaintime
|
||||||
|
|
|
@ -113,8 +113,8 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(GlobalObject& global_obj
|
||||||
MUST(fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year)));
|
MUST(fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// j. Return ? MonthDayFromFields(calendar, fields, options).
|
// j. Return ? CalendarMonthDayFromFields(calendar, fields, options).
|
||||||
return month_day_from_fields(global_object, *calendar, *fields, options);
|
return calendar_month_day_from_fields(global_object, *calendar, *fields, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Perform ? ToTemporalOverflow(options).
|
// 5. Perform ? ToTemporalOverflow(options).
|
||||||
|
@ -139,8 +139,8 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(GlobalObject& global_obj
|
||||||
auto* plain_month_day = TRY(create_temporal_month_day(global_object, result.month, result.day, *calendar, reference_iso_year));
|
auto* plain_month_day = TRY(create_temporal_month_day(global_object, result.month, result.day, *calendar, reference_iso_year));
|
||||||
|
|
||||||
// 11. NOTE: The following operation is called without options, in order for the calendar to store a canonical value in the [[ISOYear]] internal slot of the result.
|
// 11. NOTE: The following operation is called without options, in order for the calendar to store a canonical value in the [[ISOYear]] internal slot of the result.
|
||||||
// 12. Return ? MonthDayFromFields(calendar, result).
|
// 12. Return ? CalendarMonthDayFromFields(calendar, result).
|
||||||
return TRY(month_day_from_fields(global_object, *calendar, *plain_month_day));
|
return TRY(calendar_month_day_from_fields(global_object, *calendar, *plain_month_day));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.5.2 CreateTemporalMonthDay ( isoMonth, isoDay, calendar, referenceISOYear [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalmonthday
|
// 10.5.2 CreateTemporalMonthDay ( isoMonth, isoDay, calendar, referenceISOYear [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalmonthday
|
||||||
|
|
|
@ -121,8 +121,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with)
|
||||||
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
||||||
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
||||||
|
|
||||||
// 12. Return ? MonthDayFromFields(calendar, fields, options).
|
// 12. Return ? CalendarMonthDayFromFields(calendar, fields, options).
|
||||||
return TRY(month_day_from_fields(global_object, calendar, *fields, options));
|
return TRY(calendar_month_day_from_fields(global_object, calendar, *fields, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.3.7 Temporal.PlainMonthDay.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.equals
|
// 10.3.7 Temporal.PlainMonthDay.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.equals
|
||||||
|
@ -251,8 +251,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
|
||||||
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
|
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
|
||||||
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
|
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
|
||||||
|
|
||||||
// 14. Return ? DateFromFields(calendar, mergedFields, options).
|
// 14. Return ? CalendarDateFromFields(calendar, mergedFields, options).
|
||||||
return TRY(date_from_fields(global_object, calendar, *merged_fields, options));
|
return TRY(calendar_date_from_fields(global_object, calendar, *merged_fields, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.3.13 Temporal.PlainMonthDay.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.getisofields
|
// 10.3.13 Temporal.PlainMonthDay.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.getisofields
|
||||||
|
|
|
@ -57,8 +57,8 @@ ThrowCompletionOr<PlainYearMonth*> to_temporal_year_month(GlobalObject& global_o
|
||||||
// d. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
|
// d. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, item_object, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, item_object, field_names, {}));
|
||||||
|
|
||||||
// e. Return ? YearMonthFromFields(calendar, fields, options).
|
// e. Return ? CalendarYearMonthFromFields(calendar, fields, options).
|
||||||
return year_month_from_fields(global_object, *calendar, *fields, options);
|
return calendar_year_month_from_fields(global_object, *calendar, *fields, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Perform ? ToTemporalOverflow(options).
|
// 4. Perform ? ToTemporalOverflow(options).
|
||||||
|
@ -77,8 +77,8 @@ ThrowCompletionOr<PlainYearMonth*> to_temporal_year_month(GlobalObject& global_o
|
||||||
auto* creation_result = TRY(create_temporal_year_month(global_object, result.year, result.month, *calendar, result.day));
|
auto* creation_result = TRY(create_temporal_year_month(global_object, result.year, result.month, *calendar, result.day));
|
||||||
|
|
||||||
// 9. NOTE: The following operation is called without options, in order for the calendar to store a canonical value in the [[ISODay]] internal slot of the result.
|
// 9. NOTE: The following operation is called without options, in order for the calendar to store a canonical value in the [[ISODay]] internal slot of the result.
|
||||||
// 10. Return ? YearMonthFromFields(calendar, result).
|
// 10. Return ? CalendarYearMonthFromFields(calendar, result).
|
||||||
return year_month_from_fields(global_object, *calendar, *creation_result);
|
return calendar_year_month_from_fields(global_object, *calendar, *creation_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.5.2 RegulateISOYearMonth ( year, month, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulateisoyearmonth
|
// 9.5.2 RegulateISOYearMonth ( year, month, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulateisoyearmonth
|
||||||
|
|
|
@ -232,8 +232,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with)
|
||||||
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
// 11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
|
||||||
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
fields = TRY(prepare_temporal_fields(global_object, *fields, field_names, {}));
|
||||||
|
|
||||||
// 12. Return ? YearMonthFromFields(calendar, fields, options).
|
// 12. Return ? CalendarYearMonthFromFields(calendar, fields, options).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *fields, options));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *fields, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.3.12 Temporal.PlainYearMonth.prototype.add ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.add
|
// 9.3.12 Temporal.PlainYearMonth.prototype.add ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.add
|
||||||
|
@ -283,8 +283,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::add)
|
||||||
// 12. Perform ! CreateDataPropertyOrThrow(fields, "day", day).
|
// 12. Perform ! CreateDataPropertyOrThrow(fields, "day", day).
|
||||||
MUST(fields->create_data_property_or_throw(vm.names.day, Value(day)));
|
MUST(fields->create_data_property_or_throw(vm.names.day, Value(day)));
|
||||||
|
|
||||||
// 13. Let date be ? DateFromFields(calendar, fields, undefined).
|
// 13. Let date be ? CalendarDateFromFields(calendar, fields, undefined).
|
||||||
auto* date = TRY(date_from_fields(global_object, calendar, *fields, nullptr));
|
auto* date = TRY(calendar_date_from_fields(global_object, calendar, *fields, nullptr));
|
||||||
|
|
||||||
// 14. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
// 14. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
||||||
auto* duration_to_add = MUST(create_temporal_duration(global_object, duration.years, duration.months, duration.weeks, balance_result.days, 0, 0, 0, 0, 0, 0));
|
auto* duration_to_add = MUST(create_temporal_duration(global_object, duration.years, duration.months, duration.weeks, balance_result.days, 0, 0, 0, 0, 0, 0));
|
||||||
|
@ -310,8 +310,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::add)
|
||||||
// 19. Let addedDateFields be ? PrepareTemporalFields(addedDate, fieldNames, «»).
|
// 19. Let addedDateFields be ? PrepareTemporalFields(addedDate, fieldNames, «»).
|
||||||
auto* added_date_fields = TRY(prepare_temporal_fields(global_object, *added_date, field_names, {}));
|
auto* added_date_fields = TRY(prepare_temporal_fields(global_object, *added_date, field_names, {}));
|
||||||
|
|
||||||
// 20. Return ? YearMonthFromFields(calendar, addedDateFields, optionsCopy).
|
// 20. Return ? CalendarYearMonthFromFields(calendar, addedDateFields, optionsCopy).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *added_date_fields, options_copy));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *added_date_fields, options_copy));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.3.13 Temporal.PlainYearMonth.prototype.subtract ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.subtract
|
// 9.3.13 Temporal.PlainYearMonth.prototype.subtract ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.subtract
|
||||||
|
@ -368,8 +368,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::subtract)
|
||||||
// 13. Perform ! CreateDataPropertyOrThrow(fields, "day", day).
|
// 13. Perform ! CreateDataPropertyOrThrow(fields, "day", day).
|
||||||
MUST(fields->create_data_property_or_throw(vm.names.day, Value(day)));
|
MUST(fields->create_data_property_or_throw(vm.names.day, Value(day)));
|
||||||
|
|
||||||
// 14. Let date be ? DateFromFields(calendar, fields, undefined).
|
// 14. Let date be ? CalendarDateFromFields(calendar, fields, undefined).
|
||||||
auto* date = TRY(date_from_fields(global_object, calendar, *fields, nullptr));
|
auto* date = TRY(calendar_date_from_fields(global_object, calendar, *fields, nullptr));
|
||||||
|
|
||||||
// 15. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
// 15. Let durationToAdd be ! CreateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
|
||||||
auto* duration_to_add = MUST(create_temporal_duration(global_object, duration->years(), duration->months(), duration->weeks(), balance_result.days, 0, 0, 0, 0, 0, 0));
|
auto* duration_to_add = MUST(create_temporal_duration(global_object, duration->years(), duration->months(), duration->weeks(), balance_result.days, 0, 0, 0, 0, 0, 0));
|
||||||
|
@ -395,8 +395,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::subtract)
|
||||||
// 20. Let addedDateFields be ? PrepareTemporalFields(addedDate, fieldNames, «»).
|
// 20. Let addedDateFields be ? PrepareTemporalFields(addedDate, fieldNames, «»).
|
||||||
auto* added_date_fields = TRY(prepare_temporal_fields(global_object, *added_date, field_names, {}));
|
auto* added_date_fields = TRY(prepare_temporal_fields(global_object, *added_date, field_names, {}));
|
||||||
|
|
||||||
// 21. Return ? YearMonthFromFields(calendar, addedDateFields, optionsCopy).
|
// 21. Return ? CalendarYearMonthFromFields(calendar, addedDateFields, optionsCopy).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *added_date_fields, options_copy));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *added_date_fields, options_copy));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.3.14 Temporal.PlainYearMonth.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.until
|
// 9.3.14 Temporal.PlainYearMonth.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.until
|
||||||
|
@ -446,8 +446,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::until)
|
||||||
// 15. Perform ! CreateDataPropertyOrThrow(otherFields, "day", 1𝔽).
|
// 15. Perform ! CreateDataPropertyOrThrow(otherFields, "day", 1𝔽).
|
||||||
MUST(other_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
MUST(other_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
||||||
|
|
||||||
// 16. Let otherDate be ? DateFromFields(calendar, otherFields).
|
// 16. Let otherDate be ? CalendarDateFromFields(calendar, otherFields).
|
||||||
auto* other_date = TRY(date_from_fields(global_object, calendar, *other_fields));
|
auto* other_date = TRY(calendar_date_from_fields(global_object, calendar, *other_fields));
|
||||||
|
|
||||||
// 17. Let thisFields be ? PrepareTemporalFields(yearMonth, fieldNames, «»).
|
// 17. Let thisFields be ? PrepareTemporalFields(yearMonth, fieldNames, «»).
|
||||||
auto* this_fields = TRY(prepare_temporal_fields(global_object, *year_month, field_names, {}));
|
auto* this_fields = TRY(prepare_temporal_fields(global_object, *year_month, field_names, {}));
|
||||||
|
@ -455,8 +455,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::until)
|
||||||
// 18. Perform ! CreateDataPropertyOrThrow(thisFields, "day", 1𝔽).
|
// 18. Perform ! CreateDataPropertyOrThrow(thisFields, "day", 1𝔽).
|
||||||
MUST(this_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
MUST(this_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
||||||
|
|
||||||
// 19. Let thisDate be ? DateFromFields(calendar, thisFields).
|
// 19. Let thisDate be ? CalendarDateFromFields(calendar, thisFields).
|
||||||
auto* this_date = TRY(date_from_fields(global_object, calendar, *this_fields));
|
auto* this_date = TRY(calendar_date_from_fields(global_object, calendar, *this_fields));
|
||||||
|
|
||||||
// 20. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
|
// 20. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
|
||||||
auto* until_options = TRY(merge_largest_unit_option(global_object, options, *largest_unit));
|
auto* until_options = TRY(merge_largest_unit_option(global_object, options, *largest_unit));
|
||||||
|
@ -527,8 +527,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::since)
|
||||||
// 16. Perform ! CreateDataPropertyOrThrow(otherFields, "day", 1𝔽).
|
// 16. Perform ! CreateDataPropertyOrThrow(otherFields, "day", 1𝔽).
|
||||||
MUST(other_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
MUST(other_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
||||||
|
|
||||||
// 17. Let otherDate be ? DateFromFields(calendar, otherFields).
|
// 17. Let otherDate be ? CalendarDateFromFields(calendar, otherFields).
|
||||||
auto* other_date = TRY(date_from_fields(global_object, calendar, *other_fields));
|
auto* other_date = TRY(calendar_date_from_fields(global_object, calendar, *other_fields));
|
||||||
|
|
||||||
// 18. Let thisFields be ? PrepareTemporalFields(yearMonth, fieldNames, «»).
|
// 18. Let thisFields be ? PrepareTemporalFields(yearMonth, fieldNames, «»).
|
||||||
auto* this_fields = TRY(prepare_temporal_fields(global_object, *year_month, field_names, {}));
|
auto* this_fields = TRY(prepare_temporal_fields(global_object, *year_month, field_names, {}));
|
||||||
|
@ -536,8 +536,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::since)
|
||||||
// 19. Perform ! CreateDataPropertyOrThrow(thisFields, "day", 1𝔽).
|
// 19. Perform ! CreateDataPropertyOrThrow(thisFields, "day", 1𝔽).
|
||||||
MUST(this_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
MUST(this_fields->create_data_property_or_throw(vm.names.day, Value(1)));
|
||||||
|
|
||||||
// 20. Let thisDate be ? DateFromFields(calendar, thisFields).
|
// 20. Let thisDate be ? CalendarDateFromFields(calendar, thisFields).
|
||||||
auto* this_date = TRY(date_from_fields(global_object, calendar, *this_fields));
|
auto* this_date = TRY(calendar_date_from_fields(global_object, calendar, *this_fields));
|
||||||
|
|
||||||
// 21. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
|
// 21. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
|
||||||
auto* until_options = TRY(merge_largest_unit_option(global_object, options, *largest_unit));
|
auto* until_options = TRY(merge_largest_unit_option(global_object, options, *largest_unit));
|
||||||
|
@ -684,8 +684,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
|
||||||
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
|
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
|
||||||
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
|
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
|
||||||
|
|
||||||
// 14. Return ? DateFromFields(calendar, mergedFields, options).
|
// 14. Return ? CalendarDateFromFields(calendar, mergedFields, options).
|
||||||
return TRY(date_from_fields(global_object, calendar, *merged_fields, options));
|
return TRY(calendar_date_from_fields(global_object, calendar, *merged_fields, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9.3.22 Temporal.PlainYearMonth.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.getisofields
|
// 9.3.22 Temporal.PlainYearMonth.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.getisofields
|
||||||
|
|
|
@ -1401,8 +1401,8 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
|
||||||
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
|
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
|
||||||
|
|
||||||
// 9. Return ? YearMonthFromFields(calendar, fields).
|
// 9. Return ? CalendarYearMonthFromFields(calendar, fields).
|
||||||
return TRY(year_month_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_year_month_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainmonthday
|
// 6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainmonthday
|
||||||
|
@ -1430,8 +1430,8 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
|
||||||
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
|
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
|
||||||
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
|
auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
|
||||||
|
|
||||||
// 9. Return ? MonthDayFromFields(calendar, fields).
|
// 9. Return ? CalendarMonthDayFromFields(calendar, fields).
|
||||||
return TRY(month_day_from_fields(global_object, calendar, *fields));
|
return TRY(calendar_month_day_from_fields(global_object, calendar, *fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.getisofields
|
// 6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.getisofields
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue