1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

LibJS: Rename variables to 'calendarLike' in a couple of places

This is an editorial change in the Temporal spec.

See: 9af2d35
This commit is contained in:
Linus Groh 2022-02-04 19:29:15 +00:00
parent c48f695b90
commit e087cd574e
6 changed files with 36 additions and 32 deletions

View file

@ -449,11 +449,11 @@ ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&
if (is<ZonedDateTime>(item)) if (is<ZonedDateTime>(item))
return &static_cast<ZonedDateTime&>(item).calendar(); return &static_cast<ZonedDateTime&>(item).calendar();
// 2. Let calendar be ? Get(item, "calendar"). // 2. Let calendarLike be ? Get(item, "calendar").
auto calendar = TRY(item.get(vm.names.calendar)); auto calendar_like = TRY(item.get(vm.names.calendar));
// 3. Return ? ToTemporalCalendarWithISODefault(calendar). // 3. Return ? ToTemporalCalendarWithISODefault(calendarLike).
return to_temporal_calendar_with_iso_default(global_object, calendar); 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 DateFromFields ( calendar, fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-datefromfields

View file

@ -60,13 +60,13 @@ ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_ta
return TRY(create_temporal_calendar(global_object, identifier, &new_target)); return TRY(create_temporal_calendar(global_object, identifier, &new_target));
} }
// 12.3.2 Temporal.Calendar.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.from // 12.3.2 Temporal.Calendar.from ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.from
JS_DEFINE_NATIVE_FUNCTION(CalendarConstructor::from) JS_DEFINE_NATIVE_FUNCTION(CalendarConstructor::from)
{ {
auto item = vm.argument(0); auto calendar_like = vm.argument(0);
// 1. Return ? ToTemporalCalendar(item). // 1. Return ? ToTemporalCalendar(calendarLike).
return TRY(to_temporal_calendar(global_object, item)); return TRY(to_temporal_calendar(global_object, calendar_like));
} }
} }

View file

@ -60,14 +60,14 @@ JS_DEFINE_NATIVE_FUNCTION(Now::instant)
return system_instant(global_object); return system_instant(global_object);
} }
// 2.2.3 Temporal.Now.plainDateTime ( calendar [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindatetime // 2.2.3 Temporal.Now.plainDateTime ( calendarLike [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindatetime
JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_time) JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_time)
{ {
auto calendar = vm.argument(0); auto calendar_like = vm.argument(0);
auto temporal_time_zone_like = vm.argument(1); auto temporal_time_zone_like = vm.argument(1);
// 1. Return ? SystemDateTime(temporalTimeZoneLike, calendar). // 1. Return ? SystemDateTime(temporalTimeZoneLike, calendarLike).
return TRY(system_date_time(global_object, temporal_time_zone_like, calendar)); return TRY(system_date_time(global_object, temporal_time_zone_like, calendar_like));
} }
// 2.2.4 Temporal.Now.plainDateTimeISO ( [ temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindatetimeiso // 2.2.4 Temporal.Now.plainDateTimeISO ( [ temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindatetimeiso
@ -82,14 +82,14 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_time_iso)
return TRY(system_date_time(global_object, temporal_time_zone_like, calendar)); return TRY(system_date_time(global_object, temporal_time_zone_like, calendar));
} }
// 2.2.5 Temporal.Now.zonedDateTime ( calendar [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.zoneddatetime // 2.2.5 Temporal.Now.zonedDateTime ( calendarLike [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.zoneddatetime
JS_DEFINE_NATIVE_FUNCTION(Now::zoned_date_time) JS_DEFINE_NATIVE_FUNCTION(Now::zoned_date_time)
{ {
auto calendar = vm.argument(0); auto calendar_like = vm.argument(0);
auto temporal_time_zone_like = vm.argument(1); auto temporal_time_zone_like = vm.argument(1);
// 1. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendar). // 1. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendarLike).
return TRY(system_zoned_date_time(global_object, temporal_time_zone_like, calendar)); return TRY(system_zoned_date_time(global_object, temporal_time_zone_like, calendar_like));
} }
// 2.2.6 Temporal.Now.zonedDateTimeISO ( [ temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.zoneddatetimeiso // 2.2.6 Temporal.Now.zonedDateTimeISO ( [ temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.zoneddatetimeiso
@ -104,14 +104,14 @@ JS_DEFINE_NATIVE_FUNCTION(Now::zoned_date_time_iso)
return TRY(system_zoned_date_time(global_object, temporal_time_zone_like, calendar)); return TRY(system_zoned_date_time(global_object, temporal_time_zone_like, calendar));
} }
// 2.2.7 Temporal.Now.plainDate ( calendar [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindate // 2.2.7 Temporal.Now.plainDate ( calendarLike [ , temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindate
JS_DEFINE_NATIVE_FUNCTION(Now::plain_date) JS_DEFINE_NATIVE_FUNCTION(Now::plain_date)
{ {
auto calendar = vm.argument(0); auto calendar_like = vm.argument(0);
auto temporal_time_zone_like = vm.argument(1); auto temporal_time_zone_like = vm.argument(1);
// 1. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar). // 1. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendarLike).
auto* date_time = TRY(system_date_time(global_object, temporal_time_zone_like, calendar)); auto* date_time = TRY(system_date_time(global_object, temporal_time_zone_like, calendar_like));
// 2. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]). // 2. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
return TRY(create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar())); return TRY(create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar()));

View file

@ -424,15 +424,17 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
return TRY(date_from_fields(global_object, calendar, *fields, *options)); return TRY(date_from_fields(global_object, calendar, *fields, *options));
} }
// 3.3.22 Temporal.PlainDate.prototype.withCalendar ( calendar ), 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
JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with_calendar) JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with_calendar)
{ {
auto calendar_like = vm.argument(0);
// 1. Let temporalDate be the this value. // 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
auto* temporal_date = TRY(typed_this_object(global_object)); auto* temporal_date = TRY(typed_this_object(global_object));
// 3. Let calendar be ? ToTemporalCalendar(calendar). // 3. Let calendar be ? ToTemporalCalendar(calendarLike).
auto* calendar = TRY(to_temporal_calendar(global_object, vm.argument(0))); auto* calendar = TRY(to_temporal_calendar(global_object, calendar_like));
// 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar). // 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar).
return TRY(create_temporal_date(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), *calendar)); return TRY(create_temporal_date(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), *calendar));

View file

@ -442,15 +442,17 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_date)
return TRY(create_temporal_date_time(global_object, plain_date->iso_year(), plain_date->iso_month(), plain_date->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(), *calendar)); return TRY(create_temporal_date_time(global_object, plain_date->iso_year(), plain_date->iso_month(), plain_date->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(), *calendar));
} }
// 5.3.25 Temporal.PlainDateTime.prototype.withCalendar ( calendar ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withcalendar // 5.3.25 Temporal.PlainDateTime.prototype.withCalendar ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withcalendar
JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_calendar) JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_calendar)
{ {
auto calendar_like = vm.argument(0);
// 1. Let dateTime be the this value. // 1. Let dateTime be the this value.
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
auto* date_time = TRY(typed_this_object(global_object)); auto* date_time = TRY(typed_this_object(global_object));
// 3. Let calendar be ? ToTemporalCalendar(calendar). // 3. Let calendar be ? ToTemporalCalendar(calendarLike).
auto* calendar = TRY(to_temporal_calendar(global_object, vm.argument(0))); auto* calendar = TRY(to_temporal_calendar(global_object, calendar_like));
// 4. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], calendar). // 4. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], calendar).
return TRY(create_temporal_date_time(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(), *calendar)); return TRY(create_temporal_date_time(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(), *calendar));

View file

@ -80,17 +80,17 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(GlobalObject& global_obj
calendar = &static_cast<ZonedDateTime&>(item_object).calendar(); calendar = &static_cast<ZonedDateTime&>(item_object).calendar();
calendar_absent = false; calendar_absent = false;
} else { } else {
// i. Let calendar be ? Get(item, "calendar"). // i. Let calendarLike be ? Get(item, "calendar").
auto calendar_value = TRY(item_object.get(vm.names.calendar)); auto calendar_like = TRY(item_object.get(vm.names.calendar));
// ii. If calendar is undefined, then // ii. If calendarLike is undefined, then
// 1. Let calendarAbsent be true. // 1. Let calendarAbsent be true.
// iii. Else, // iii. Else,
// 1. Let calendarAbsent be false. // 1. Let calendarAbsent be false.
calendar_absent = calendar_value.is_undefined(); calendar_absent = calendar_like.is_undefined();
// iv. Set calendar to ? ToTemporalCalendarWithISODefault(calendar). // iv. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
calendar = TRY(to_temporal_calendar_with_iso_default(global_object, calendar_value)); calendar = TRY(to_temporal_calendar_with_iso_default(global_object, calendar_like));
} }
// d. Let fieldNames be ? CalendarFields(calendar, « "day", "month", "monthCode", "year" »). // d. Let fieldNames be ? CalendarFields(calendar, « "day", "month", "monthCode", "year" »).