Skip to content

Commit

Permalink
[JSC] Remove obsoleted methods for Temporal.PlainTime and Temporal.Pl…
Browse files Browse the repository at this point in the history
…ainDateTime

https://bugs.webkit.org/show_bug.cgi?id=279312

Reviewed by NOBODY (OOPS!).

Due to changes in Temporal from July 2024, several methods have become obsolete[1]. We have already
removed the methods of Temporal.Instant that were marked obsolete[2].

This patch removes the following methods from Temporal.PlainTime and Temporal.PlainDateTime:

- Temporal.PlainTime.prototype.toPlainDateTime
- Temporal.PlainDateTime.prototype.withPlainDate

Although there are other methods slated for removal in the Temporal changes[1], we had not yet
implemented those methods.

[1]: tc39/proposal-temporal#2895
[2]: https://commits.webkit.org/282400@main

* JSTests/stress/temporal-plaindatetime.js:
* JSTests/stress/temporal-plaintime.js:
(shouldBe.String.Temporal.PlainTime.from):
* Source/JavaScriptCore/runtime/TemporalPlainDateTimePrototype.cpp:
* Source/JavaScriptCore/runtime/TemporalPlainTimePrototype.cpp:
  • Loading branch information
sosukesuzuki committed Sep 8, 2024
1 parent 792eaa7 commit 2726337
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 43 deletions.
4 changes: 0 additions & 4 deletions JSTests/stress/temporal-plaindatetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ shouldBe(pdt.with({ second: 15 }).toString(), '0001-02-03T04:05:15.007008009');
shouldBe(pdt.with({ day: 30 }).toString(), '0001-02-28T04:05:06.007008009');
shouldThrow(() => { pdt.with({ day: 30 }, { overflow: 'reject' }); }, RangeError);

shouldBe(Temporal.PlainDateTime.prototype.withPlainDate.length, 1);
shouldThrow(() => { pdt.withPlainDate(); }, TypeError);
shouldBe(pdt.withPlainDate({ year: 2000, month: 10, day: 30 }).toString(), '2000-10-30T04:05:06.007008009');

shouldBe(Temporal.PlainDateTime.prototype.withPlainTime.length, 0);
shouldBe(pdt.withPlainTime().toString(), '0001-02-03T00:00:00');
shouldBe(pdt.withPlainTime({ hour: 1, minute: 2, second: 3 }).toString(), '0001-02-03T01:02:03');
Expand Down
3 changes: 0 additions & 3 deletions JSTests/stress/temporal-plaintime.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ shouldBe(String(Temporal.PlainTime.from('2007-01-09 03:24:30[u-ca=japanese]')),
let dateTime = Temporal.PlainDateTime.from('1995-12-07T03:24:30+01:00[Europe/Brussels]')
shouldBe(Temporal.PlainTime.from(dateTime).toString(), time.toString());

let date = Temporal.PlainDate.from('1995-12-07T03:24:30+01:00[Europe/Brussels]');
shouldBe(time.toPlainDateTime(date).toString(), dateTime.toString());

shouldBe(time.toJSON(), time.toString());
shouldBe(time.toLocaleString(), time.toString());
}
Expand Down
18 changes: 0 additions & 18 deletions Source/JavaScriptCore/runtime/TemporalPlainDateTimePrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncGetISOFields)
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncAdd);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncSubtract);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWith);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWithPlainDate);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWithPlainTime);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncRound);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncEquals);
Expand Down Expand Up @@ -84,7 +83,6 @@ const ClassInfo TemporalPlainDateTimePrototype::s_info = { "Temporal.PlainDateTi
add temporalPlainDateTimePrototypeFuncAdd DontEnum|Function 1
subtract temporalPlainDateTimePrototypeFuncSubtract DontEnum|Function 1
with temporalPlainDateTimePrototypeFuncWith DontEnum|Function 1
withPlainDate temporalPlainDateTimePrototypeFuncWithPlainDate DontEnum|Function 1
withPlainTime temporalPlainDateTimePrototypeFuncWithPlainTime DontEnum|Function 0
round temporalPlainDateTimePrototypeFuncRound DontEnum|Function 1
equals temporalPlainDateTimePrototypeFuncEquals DontEnum|Function 1
Expand Down Expand Up @@ -243,22 +241,6 @@ JSC_DEFINE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWith, (JSGlobalObject
RELEASE_AND_RETURN(scope, JSValue::encode(plainDateTime->with(globalObject, asObject(temporalDateTimeLike), callFrame->argument(1))));
}

// https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withplaindate
JSC_DEFINE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWithPlainDate, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);

auto* plainDateTime = jsDynamicCast<TemporalPlainDateTime*>(callFrame->thisValue());
if (!plainDateTime)
return throwVMTypeError(globalObject, scope, "Temporal.PlainDateTime.prototype.withPlainDate called on value that's not a PlainDateTime"_s);

auto* plainDate = TemporalPlainDate::from(globalObject, callFrame->argument(0), std::nullopt);
RETURN_IF_EXCEPTION(scope, { });

RELEASE_AND_RETURN(scope, JSValue::encode(TemporalPlainDateTime::tryCreateIfValid(globalObject, globalObject->plainDateTimeStructure(), plainDate->plainDate(), plainDateTime->plainTime())));
}

// https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withplaintime
JSC_DEFINE_HOST_FUNCTION(temporalPlainDateTimePrototypeFuncWithPlainTime, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
Expand Down
18 changes: 0 additions & 18 deletions Source/JavaScriptCore/runtime/TemporalPlainTimePrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncSince);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncRound);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncEquals);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncGetISOFields);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToPlainDateTime);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToString);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToJSON);
static JSC_DECLARE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToLocaleString);
Expand Down Expand Up @@ -74,7 +73,6 @@ const ClassInfo TemporalPlainTimePrototype::s_info = { "Temporal.PlainTime"_s, &
round temporalPlainTimePrototypeFuncRound DontEnum|Function 1
equals temporalPlainTimePrototypeFuncEquals DontEnum|Function 1
getISOFields temporalPlainTimePrototypeFuncGetISOFields DontEnum|Function 0
toPlainDateTime temporalPlainTimePrototypeFuncToPlainDateTime DontEnum|Function 1
toString temporalPlainTimePrototypeFuncToString DontEnum|Function 0
toJSON temporalPlainTimePrototypeFuncToJSON DontEnum|Function 0
toLocaleString temporalPlainTimePrototypeFuncToLocaleString DontEnum|Function 0
Expand Down Expand Up @@ -266,22 +264,6 @@ JSC_DEFINE_HOST_FUNCTION(temporalPlainTimePrototypeFuncGetISOFields, (JSGlobalOb
return JSValue::encode(fields);
}

// https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.toplaindatetime
JSC_DEFINE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToPlainDateTime, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);

auto* plainTime = jsDynamicCast<TemporalPlainTime*>(callFrame->thisValue());
if (!plainTime)
return throwVMTypeError(globalObject, scope, "Temporal.PlainTime.prototype.toPlainDateTime called on value that's not a PlainTime"_s);

auto* plainDate = TemporalPlainDate::from(globalObject, callFrame->argument(0), std::nullopt);
RETURN_IF_EXCEPTION(scope, { });

RELEASE_AND_RETURN(scope, JSValue::encode(TemporalPlainDateTime::tryCreateIfValid(globalObject, globalObject->plainDateTimeStructure(), plainDate->plainDate(), plainTime->plainTime())));
}

// https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tostring
JSC_DEFINE_HOST_FUNCTION(temporalPlainTimePrototypeFuncToString, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
Expand Down

0 comments on commit 2726337

Please sign in to comment.