Browse Source

Temporal: attribute/property and custom calendar fixes (#3639)

* Fix accessor attribute and toStringTag property

* Fix calendar methods and custom extends calendar calling

* Complete attribute update

* run cargo fmt
pull/3642/head
Kevin 11 months ago committed by GitHub
parent
commit
8f7028d112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 62
      core/engine/src/builtins/temporal/calendar/mod.rs
  2. 36
      core/engine/src/builtins/temporal/calendar/object.rs
  3. 56
      core/engine/src/builtins/temporal/duration/mod.rs
  4. 10
      core/engine/src/builtins/temporal/instant/mod.rs
  5. 40
      core/engine/src/builtins/temporal/plain_date/mod.rs
  6. 2
      core/engine/src/builtins/temporal/plain_date_time/mod.rs
  7. 2
      core/engine/src/builtins/temporal/plain_month_day/mod.rs
  8. 12
      core/engine/src/builtins/temporal/plain_time/mod.rs
  9. 28
      core/engine/src/builtins/temporal/plain_year_month/mod.rs
  10. 2
      core/engine/src/builtins/temporal/time_zone/mod.rs
  11. 2
      core/engine/src/builtins/temporal/zoned_date_time/mod.rs
  12. 4
      core/temporal/src/components/date.rs
  13. 4
      core/temporal/src/components/datetime.rs

62
core/engine/src/builtins/temporal/calendar/mod.rs

@ -73,12 +73,12 @@ impl IntrinsicObject for Calendar {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
)
.accessor(utf16!("id"), Some(get_id), None, Attribute::default())
.accessor(utf16!("id"), Some(get_id), None, Attribute::CONFIGURABLE)
.static_method(Self::from, js_string!("from"), 1)
.method(Self::date_from_fields, js_string!("dateFromFields"), 2)
.method(
@ -174,8 +174,9 @@ impl Calendar {
.as_object()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("the this value of Calendar must be a Calendar object.")
JsNativeError::typ().with_message(
"the this value of Calendar.prototype.id must be a Calendar object.",
)
})?;
Ok(JsString::from(calendar.slot.identifier(context)?.as_str()).into())
@ -193,8 +194,9 @@ impl Calendar {
.as_object()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
JsNativeError::typ().with_message(
"this value of Calendar dateFromFields must be a Calendar object.",
)
})?;
// 3. If Type(fields) is not Object, throw a TypeError exception.
@ -273,8 +275,9 @@ impl Calendar {
.as_object()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
JsNativeError::typ().with_message(
"this value of Calendar yearMonthFromFields must be a Calendar object.",
)
})?;
let fields = args.get_or_undefined(0);
@ -349,8 +352,9 @@ impl Calendar {
.as_object()
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
JsNativeError::typ().with_message(
"this value of Calendar monthDayFromFields must be a Calendar object.",
)
})?;
// 3. If Type(fields) is not Object, throw a TypeError exception.
@ -422,7 +426,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar dateAdd must be a Calendar object.")
})?;
// 4. Set date to ? ToTemporalDate(date).
@ -461,7 +465,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar dateUntil must be a Calendar object.")
})?;
// 4. Set one to ? ToTemporalDate(one).
@ -497,7 +501,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar era must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -517,7 +521,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar eraYear must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -537,7 +541,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar year must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -554,7 +558,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar month must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -576,7 +580,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar monthCode must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -593,7 +597,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar day must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -612,7 +616,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar dayOfWeek must be a Calendar object.")
})?;
// 3. Let temporalDate be ? ToTemporalDate(temporalDateLike).
@ -632,7 +636,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar dayOfYear must be a Calendar object.")
})?;
// 3. Let temporalDate be ? ToTemporalDate(temporalDateLike).
@ -652,7 +656,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar weekOfYear must be a Calendar object.")
})?;
// 3. Let temporalDate be ? ToTemporalDate(temporalDateLike).
@ -672,7 +676,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar yearOfWeek must be a Calendar object.")
})?;
// 3. Let temporalDate be ? ToTemporalDate(temporalDateLike).
@ -692,7 +696,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar daysInWeek must be a Calendar object.")
})?;
// 3. Let temporalDate be ? ToTemporalDate(temporalDateLike).
@ -712,7 +716,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar daysInMonth must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -729,7 +733,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar daysInYear must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -749,7 +753,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar monthsInYear must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -766,7 +770,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar inLeapYear must be a Calendar object.")
})?;
let date_like = to_calendar_date_like(args.get_or_undefined(0), context)?;
@ -785,7 +789,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar Fields must be a Calendar object.")
})?;
// Custom Calendars override the `fields` method.
@ -902,7 +906,7 @@ impl Calendar {
.and_then(JsObject::downcast_ref::<Self>)
.ok_or_else(|| {
JsNativeError::typ()
.with_message("this value of Calendar must be a Calendar object.")
.with_message("this value of Calendar mergeFields must be a Calendar object.")
})?;
let fields = args.get_or_undefined(0).to_object(context)?;

36
core/engine/src/builtins/temporal/calendar/object.rs

@ -267,7 +267,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -314,7 +314,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -361,7 +361,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
let JsValue::String(result) = val else {
@ -393,7 +393,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -440,7 +440,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -489,7 +489,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -538,7 +538,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -587,7 +587,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -629,7 +629,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -677,7 +677,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -728,7 +728,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -777,7 +777,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
// Validate the return value.
@ -828,7 +828,7 @@ impl CalendarProtocol for JsCustomCalendar {
let val = method
.as_callable()
.expect("is method")
.call(&method, &[date_like], context)
.call(&self.calendar.clone().into(), &[date_like], context)
.map_err(|err| TemporalError::general(err.to_string()))?;
let JsValue::Boolean(result) = val else {
@ -858,7 +858,7 @@ impl CalendarProtocol for JsCustomCalendar {
let result = method
.as_callable()
.expect("is method")
.call(&method, &[fields_js.into()], context)
.call(&self.calendar.clone().into(), &[fields_js.into()], context)
.map_err(|e| TemporalError::general(e.to_string()))?;
// validate result and map to a `Vec<String>`
@ -909,7 +909,11 @@ impl CalendarProtocol for JsCustomCalendar {
let value = method
.as_callable()
.expect("is method")
.call(&method, &[fields.into(), add_fields.into()], context)
.call(
&self.calendar.clone().into(),
&[fields.into(), add_fields.into()],
context,
)
.map_err(|e| TemporalError::general(e.to_string()))?;
let JsValue::Object(o) = value else {
@ -930,7 +934,7 @@ impl CalendarProtocol for JsCustomCalendar {
.calendar
.__get__(
&PropertyKey::from(utf16!("id")),
JsValue::undefined(),
self.calendar.clone().into(),
&mut context.into(),
)
.expect("method must exist on a object that implements the CalendarProtocol.");

56
core/engine/src/builtins/temporal/duration/mod.rs

@ -101,53 +101,83 @@ impl IntrinsicObject for Duration {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.accessor(utf16!("years"), Some(get_years), None, Attribute::default())
.accessor(
utf16!("years"),
Some(get_years),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("months"),
Some(get_months),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("weeks"),
Some(get_weeks),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("days"),
Some(get_days),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("hours"),
Some(get_hours),
None,
Attribute::CONFIGURABLE,
)
.accessor(utf16!("weeks"), Some(get_weeks), None, Attribute::default())
.accessor(utf16!("days"), Some(get_days), None, Attribute::default())
.accessor(utf16!("hours"), Some(get_hours), None, Attribute::default())
.accessor(
utf16!("minutes"),
Some(get_minutes),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("seconds"),
Some(get_seconds),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("milliseconds"),
Some(get_milliseconds),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("microseconds"),
Some(get_microseconds),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("nanoseconds"),
Some(get_nanoseconds),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("sign"),
Some(get_sign),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("blank"),
Some(is_blank),
None,
Attribute::CONFIGURABLE,
)
.accessor(utf16!("sign"), Some(get_sign), None, Attribute::default())
.accessor(utf16!("blank"), Some(is_blank), None, Attribute::default())
.method(Self::with, js_string!("with"), 1)
.method(Self::negated, js_string!("negated"), 0)
.method(Self::abs, js_string!("abs"), 0)

10
core/engine/src/builtins/temporal/instant/mod.rs

@ -58,7 +58,7 @@ impl IntrinsicObject for Instant {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
@ -67,25 +67,25 @@ impl IntrinsicObject for Instant {
utf16!("epochSeconds"),
Some(get_seconds),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("epochMilliseconds"),
Some(get_millis),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("epochMicroseconds"),
Some(get_micros),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("epochNanoseconds"),
Some(get_nanos),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)

40
core/engine/src/builtins/temporal/plain_date/mod.rs

@ -103,7 +103,7 @@ impl IntrinsicObject for PlainDate {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
@ -112,70 +112,80 @@ impl IntrinsicObject for PlainDate {
utf16!("calendarId"),
Some(get_calendar_id),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("year"),
Some(get_year),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("month"),
Some(get_month),
None,
Attribute::CONFIGURABLE,
)
.accessor(utf16!("year"), Some(get_year), None, Attribute::default())
.accessor(utf16!("month"), Some(get_month), None, Attribute::default())
.accessor(
utf16!("monthCode"),
Some(get_month_code),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(utf16!("day"), Some(get_day), None, Attribute::default())
.accessor(utf16!("day"), Some(get_day), None, Attribute::CONFIGURABLE)
.accessor(
utf16!("dayOfWeek"),
Some(get_day_of_week),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("dayOfYear"),
Some(get_day_of_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("weekOfYear"),
Some(get_week_of_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("yearOfWeek"),
Some(get_year_of_week),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("daysInWeek"),
Some(get_days_in_week),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("daysInMonth"),
Some(get_days_in_month),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("daysInYear"),
Some(get_days_in_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("monthsInYear"),
Some(get_months_in_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("inLeapYear"),
Some(get_in_leap_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.method(Self::to_plain_year_month, js_string!("toPlainYearMonth"), 0)
.method(Self::to_plain_month_day, js_string!("toPlainMonthDay"), 0)

2
core/engine/src/builtins/temporal/plain_date_time/mod.rs

@ -127,7 +127,7 @@ impl IntrinsicObject for PlainDateTime {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,

2
core/engine/src/builtins/temporal/plain_month_day/mod.rs

@ -38,7 +38,7 @@ impl IntrinsicObject for PlainMonthDay {
let _timer = Profiler::global().start_event(std::any::type_name::<Self>(), "init");
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,

12
core/engine/src/builtins/temporal/plain_time/mod.rs

@ -66,7 +66,7 @@ impl IntrinsicObject for PlainTime {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
@ -76,31 +76,31 @@ impl IntrinsicObject for PlainTime {
utf16!("minute"),
Some(get_minute),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("second"),
Some(get_second),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("millisecond"),
Some(get_millisecond),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("microsecond"),
Some(get_microsecond),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("nanosecond"),
Some(get_nanosecond),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.method(Self::add, js_string!("add"), 1)
.method(Self::subtract, js_string!("subtract"), 1)

28
core/engine/src/builtins/temporal/plain_year_month/mod.rs

@ -70,7 +70,7 @@ impl IntrinsicObject for PlainYearMonth {
.build();
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
@ -79,39 +79,49 @@ impl IntrinsicObject for PlainYearMonth {
utf16!("calendarId"),
Some(get_calendar_id),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("year"),
Some(get_year),
None,
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("month"),
Some(get_month),
None,
Attribute::CONFIGURABLE,
)
.accessor(utf16!("year"), Some(get_year), None, Attribute::default())
.accessor(utf16!("month"), Some(get_month), None, Attribute::default())
.accessor(
utf16!("monthCode"),
Some(get_month_code),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("daysInMonth"),
Some(get_days_in_month),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("daysInYear"),
Some(get_days_in_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("monthsInYear"),
Some(get_months_in_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.accessor(
utf16!("inLeapYear"),
Some(get_in_leap_year),
None,
Attribute::default(),
Attribute::CONFIGURABLE,
)
.method(Self::with, js_string!("with"), 2)
.method(Self::add, js_string!("add"), 2)

2
core/engine/src/builtins/temporal/time_zone/mod.rs

@ -85,7 +85,7 @@ impl IntrinsicObject for TimeZone {
)
.method(Self::to_string, js_string!("toString"), 0)
.method(Self::to_string, js_string!("toJSON"), 0)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,

2
core/engine/src/builtins/temporal/zoned_date_time/mod.rs

@ -44,7 +44,7 @@ impl IntrinsicObject for ZonedDateTime {
let _timer = Profiler::global().start_event(std::any::type_name::<Self>(), "init");
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.static_property(
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,

4
core/temporal/src/components/date.rs

@ -195,7 +195,7 @@ impl<C: CalendarProtocol> Date<C> {
/// Returns the calendar day of year value with provided context.
pub fn contextual_day_of_year(&self, context: &mut dyn Any) -> TemporalResult<u16> {
self.calendar.day_of_week(
self.calendar.day_of_year(
&super::calendar::CalendarDateLike::Date(self.clone()),
context,
)
@ -203,7 +203,7 @@ impl<C: CalendarProtocol> Date<C> {
/// Returns the calendar day of year value.
pub fn day_of_year(&self) -> TemporalResult<u16> {
self.contextual_day_of_week(&mut ())
self.contextual_day_of_year(&mut ())
}
/// Returns the calendar week of year value with provided context.

4
core/temporal/src/components/datetime.rs

@ -238,7 +238,7 @@ impl<C: CalendarProtocol> DateTime<C> {
/// Returns the calendar day of year value with provided context.
pub fn contextual_day_of_year(&self, context: &mut dyn Any) -> TemporalResult<u16> {
self.calendar.day_of_week(
self.calendar.day_of_year(
&super::calendar::CalendarDateLike::DateTime(self.clone()),
context,
)
@ -246,7 +246,7 @@ impl<C: CalendarProtocol> DateTime<C> {
/// Returns the calendar day of year value.
pub fn day_of_year(&self) -> TemporalResult<u16> {
self.contextual_day_of_week(&mut ())
self.contextual_day_of_year(&mut ())
}
/// Returns the calendar week of year value with provided context.

Loading…
Cancel
Save