mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Implement Temporal.PlainDateTime.{ toPlainTime, toPlainDate }
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
5e5eb5d631
commit
dc7640a152
5 changed files with 29 additions and 14 deletions
|
|
@ -746,6 +746,18 @@ static Value builtinTemporalPlainDateTimeEquals(ExecutionState& state, Value thi
|
|||
return Value(plainDateTime->equals(state, argv[0]));
|
||||
}
|
||||
|
||||
static Value builtinTemporalPlainDateTimeToPlainDate(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
RESOLVE_THIS_BINDING_TO_PLAINDATETIME(plainDateTime, ToPlainDate);
|
||||
return plainDateTime->toPlainDate(state);
|
||||
}
|
||||
|
||||
static Value builtinTemporalPlainDateTimeToPlainTime(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
RESOLVE_THIS_BINDING_TO_PLAINDATETIME(plainDateTime, ToPlainTime);
|
||||
return plainDateTime->toPlainTime(state);
|
||||
}
|
||||
|
||||
static Value builtinTemporalPlainYearMonthConstructor(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
// If NewTarget is undefined, throw a TypeError exception.
|
||||
|
|
@ -1319,6 +1331,8 @@ void GlobalObject::installTemporal(ExecutionState& state)
|
|||
m_temporalPlainDateTimePrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->lazySince()), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->lazySince(), builtinTemporalPlainDateTimeSince, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_temporalPlainDateTimePrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->round), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->round, builtinTemporalPlainDateTimeRound, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_temporalPlainDateTimePrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->lazyEquals()), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->lazyEquals(), builtinTemporalPlainDateTimeEquals, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_temporalPlainDateTimePrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->lazyToPlainDate()), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->lazyToPlainDate(), builtinTemporalPlainDateTimeToPlainDate, 0, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_temporalPlainDateTimePrototype->directDefineOwnProperty(state, ObjectPropertyName(strings->lazyToPlainTime()), ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(strings->lazyToPlainTime(), builtinTemporalPlainDateTimeToPlainTime, 0, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
|
||||
{
|
||||
AtomicString name(state.context(), "get calendarId");
|
||||
|
|
|
|||
|
|
@ -1011,6 +1011,8 @@ namespace Escargot {
|
|||
F(TemporalDotPlainMonthDay, "Temporal.PlainMonthDay") \
|
||||
F(TemporalDotPlainYearMonth, "Temporal.PlainYearMonth") \
|
||||
F(ToPlainDate, "toPlainDate") \
|
||||
F(ToPlainDateTime, "toPlainDateTime") \
|
||||
F(ToPlainTime, "toPlainTime") \
|
||||
F(TimeZoneId, "timeZoneId") \
|
||||
F(Until, "until") \
|
||||
F(WeekOfYear, "weekOfYear") \
|
||||
|
|
|
|||
|
|
@ -375,6 +375,16 @@ bool TemporalPlainDateTimeObject::equals(ExecutionState& state, Value otherInput
|
|||
return calendarID() == other->calendarID();
|
||||
}
|
||||
|
||||
TemporalPlainDateObject* TemporalPlainDateTimeObject::toPlainDate(ExecutionState& state)
|
||||
{
|
||||
return new TemporalPlainDateObject(state, state.context()->globalObject()->temporalPlainDatePrototype(), computeISODate(state), calendarID());
|
||||
}
|
||||
|
||||
TemporalPlainTimeObject* TemporalPlainDateTimeObject::toPlainTime(ExecutionState& state)
|
||||
{
|
||||
return new TemporalPlainTimeObject(state, state.context()->globalObject()->temporalPlainTimePrototype(), plainTime());
|
||||
}
|
||||
|
||||
} // namespace Escargot
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -143,6 +143,9 @@ public:
|
|||
// https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.equals
|
||||
bool equals(ExecutionState& state, Value otherInput);
|
||||
|
||||
TemporalPlainDateObject* toPlainDate(ExecutionState& state);
|
||||
TemporalPlainTimeObject* toPlainTime(ExecutionState& state);
|
||||
|
||||
private:
|
||||
ISO8601::PlainDateTime* m_plainDateTime;
|
||||
Calendar m_calendarID;
|
||||
|
|
|
|||
|
|
@ -588,20 +588,6 @@
|
|||
<test id="built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-negative-epochnanoseconds"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/branding"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/builtin"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/length"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/limits"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/name"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/not-a-constructor"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainDate/prop-desc"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/basic"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/branding"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/builtin"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/length"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/name"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/not-a-constructor"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toPlainTime/prop-desc"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/toString/rounding-edge-of-range"><reason>TODO</reason></test>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue