|
|
|
@ -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)?; |
|
|
|
|