diff --git a/Cargo.lock b/Cargo.lock index 70b4ba3ddaa..c1cae5627e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4059,9 +4059,9 @@ dependencies = [ [[package]] name = "temporal_rs" -version = "0.0.12" +version = "0.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcd01e4b1d98e5d846523404ef2385ae1d37dcf61046d881d9401b23e4820386" +checksum = "867c429d5aec157c6d4c255366315f5d0d4a3521171d4429c6c0a382812c0034" dependencies = [ "combine", "core_maths", @@ -4206,9 +4206,9 @@ dependencies = [ [[package]] name = "timezone_provider" -version = "0.0.12" +version = "0.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712d45c4f715eebee4896f69dbbac86cbbb8bf594832000cc209d923936cfb4a" +checksum = "f357f8e2cddee6a7b56b69fbb4cab30a7e82914c80ee7f9a5eb799ee3de3f24d" dependencies = [ "tinystr", "zerotrie", diff --git a/Cargo.toml b/Cargo.toml index 1cd99bd361c..853c01e9c9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ intrusive-collections = "0.9.7" cfg-if = "1.0.1" either = "1.15.0" sys-locale = "0.3.2" -temporal_rs = { version = "0.0.12", default-features = false, features = [ +temporal_rs = { version = "0.0.14", default-features = false, features = [ "tzdb", ] } web-time = "1.1.0" diff --git a/core/engine/src/builtins/temporal/instant/mod.rs b/core/engine/src/builtins/temporal/instant/mod.rs index 39f801f99f5..ea08cbdbc5a 100644 --- a/core/engine/src/builtins/temporal/instant/mod.rs +++ b/core/engine/src/builtins/temporal/instant/mod.rs @@ -362,7 +362,7 @@ impl Instant { // 3. Return ? AddDurationToOrSubtractDurationFromInstant(add, instant, temporalDurationLike). let temporal_duration_like = to_temporal_duration_record(args.get_or_undefined(0), context)?; - let result = instant.inner.add(temporal_duration_like)?; + let result = instant.inner.add(&temporal_duration_like)?; create_temporal_instant(result, None, context) } @@ -395,7 +395,7 @@ impl Instant { // 3. Return ? AddDurationToOrSubtractDurationFromInstant(subtract, instant, temporalDurationLike). let temporal_duration_like = to_temporal_duration_record(args.get_or_undefined(0), context)?; - let result = instant.inner.subtract(temporal_duration_like)?; + let result = instant.inner.subtract(&temporal_duration_like)?; create_temporal_instant(result, None, context) } @@ -756,7 +756,9 @@ impl Instant { let timezone = to_temporal_timezone_identifier(args.get_or_undefined(0), context)?; // 4. Return ! CreateTemporalZonedDateTime(instant.[[EpochNanoseconds]], timeZone, "iso8601"). - let zdt = instant.inner.to_zoned_date_time_iso(timezone); + let zdt = instant + .inner + .to_zoned_date_time_iso_with_provider(timezone, context.tz_provider())?; create_temporal_zoneddatetime(zdt, None, context).map(Into::into) } } diff --git a/core/engine/src/builtins/temporal/now.rs b/core/engine/src/builtins/temporal/now.rs index f40039f5d69..5319e4eb18e 100644 --- a/core/engine/src/builtins/temporal/now.rs +++ b/core/engine/src/builtins/temporal/now.rs @@ -147,7 +147,7 @@ impl Now { .transpose()?; let now = build_now(context)?; - let zdt = now.zoned_date_time_iso(time_zone)?; + let zdt = now.zoned_date_time_iso_with_provider(time_zone, context.tz_provider())?; create_temporal_zoneddatetime(zdt, None, context).map(Into::into) } diff --git a/core/engine/src/builtins/temporal/plain_date/mod.rs b/core/engine/src/builtins/temporal/plain_date/mod.rs index a5946c3fefc..aa27f836e1a 100644 --- a/core/engine/src/builtins/temporal/plain_date/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date/mod.rs @@ -1337,10 +1337,7 @@ pub(crate) fn to_temporal_date( // ii. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). // iii. Let plainDateTime be ? GetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]). // iv. Return ! CreateTemporalDate(plainDateTime.[[ISOYear]], plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], plainDateTime.[[Calendar]]). - return zdt - .inner - .to_plain_date_with_provider(context.tz_provider()) - .map_err(Into::into); + return zdt.inner.to_plain_date().map_err(Into::into); // c. If item has an [[InitializedTemporalDateTime]] internal slot, then } else if let Some(dt) = object.downcast_ref::() { let options_obj = get_options_object(&options)?; diff --git a/core/engine/src/builtins/temporal/plain_date_time/mod.rs b/core/engine/src/builtins/temporal/plain_date_time/mod.rs index f8cb4886b5d..42d414c4129 100644 --- a/core/engine/src/builtins/temporal/plain_date_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_date_time/mod.rs @@ -1677,10 +1677,7 @@ pub(crate) fn to_temporal_datetime( // ii. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]). // iii. Let timeZoneRec be ? CreateTimeZoneMethodsRecord(item.[[TimeZone]], « get-offset-nanoseconds-for »). // iv. Return ? GetPlainDateTimeFor(timeZoneRec, instant, item.[[Calendar]]). - return zdt - .inner - .to_plain_datetime_with_provider(context.tz_provider()) - .map_err(Into::into); + return zdt.inner.to_plain_datetime().map_err(Into::into); // c. If item has an [[InitializedTemporalDate]] internal slot, then } else if let Some(date) = object.downcast_ref::() { // i. Perform ? GetTemporalOverflowOption(resolvedOptions). diff --git a/core/engine/src/builtins/temporal/plain_time/mod.rs b/core/engine/src/builtins/temporal/plain_time/mod.rs index 62d0fb5ca0e..7a23e426358 100644 --- a/core/engine/src/builtins/temporal/plain_time/mod.rs +++ b/core/engine/src/builtins/temporal/plain_time/mod.rs @@ -911,10 +911,7 @@ pub(crate) fn to_temporal_time( let options = get_options_object(options)?; let _overflow = get_option::(&options, js_string!("overflow"), context)?; - return zdt - .inner - .to_plain_time_with_provider(context.tz_provider()) - .map_err(Into::into); + return zdt.inner.to_plain_time().map_err(Into::into); // c. If item has an [[InitializedTemporalDateTime]] internal slot, then } else if let Some(dt) = object.downcast_ref::() { // i. Return ! CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], diff --git a/core/engine/src/builtins/temporal/zoneddatetime/mod.rs b/core/engine/src/builtins/temporal/zoneddatetime/mod.rs index 2711e3d0409..5607e661da8 100644 --- a/core/engine/src/builtins/temporal/zoneddatetime/mod.rs +++ b/core/engine/src/builtins/temporal/zoneddatetime/mod.rs @@ -451,7 +451,12 @@ impl BuiltInConstructor for ZonedDateTime { .transpose()? .unwrap_or_default(); - let inner = ZonedDateTimeInner::try_new(epoch_nanos.to_i128(), calendar, timezone)?; + let inner = ZonedDateTimeInner::try_new_with_provider( + epoch_nanos.to_i128(), + calendar, + timezone, + context.tz_provider(), + )?; // 11. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget). create_temporal_zoneddatetime(inner, Some(new_target), context).map(Into::into) @@ -518,7 +523,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.era /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/era /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.era - fn get_era(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_era(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -527,7 +532,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - let era = zdt.inner.era_with_provider(context.tz_provider())?; + let era = zdt.inner.era()?; Ok(era .map(|tinystr| JsString::from(tinystr.cow_to_lowercase())) .into_or_undefined()) @@ -544,7 +549,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.erayear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/eraYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.era_year - fn get_era_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_era_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -553,10 +558,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .era_year_with_provider(context.tz_provider())? - .into_or_undefined()) + Ok(zdt.inner.era_year()?.into_or_undefined()) } /// 6.3.7 get `Temporal.ZonedDateTime.prototype.year` @@ -570,7 +572,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.year /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/year /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.year - fn get_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -579,7 +581,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt.inner.year_with_provider(context.tz_provider())?.into()) + Ok(zdt.inner.year()?.into()) } /// 6.3.8 get `Temporal.ZonedDateTime.prototype.month` @@ -593,7 +595,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.month /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/month /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.month - fn get_month(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -602,7 +604,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt.inner.month_with_provider(context.tz_provider())?.into()) + Ok(zdt.inner.month()?.into()) } /// 6.3.9 get `Temporal.ZonedDateTime.prototype.monthCode` @@ -616,7 +618,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthcode /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/monthCode /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.month_code - fn get_month_code(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_month_code(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -625,12 +627,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(JsString::from( - zdt.inner - .month_code_with_provider(context.tz_provider())? - .as_str(), - ) - .into()) + Ok(JsString::from(zdt.inner.month_code()?.as_str()).into()) } /// 6.3.10 get `Temporal.ZonedDateTime.prototype.day` @@ -644,7 +641,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.day /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/day /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.day - fn get_day(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_day(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -653,7 +650,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt.inner.day_with_provider(context.tz_provider())?.into()) + Ok(zdt.inner.day()?.into()) } /// 6.3.11 get `Temporal.ZonedDateTime.prototype.hour` @@ -667,7 +664,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.hour /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/hour /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.hour - fn get_hour(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_hour(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -676,7 +673,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt.inner.hour_with_provider(context.tz_provider())?.into()) + Ok(zdt.inner.hour()?.into()) } /// 6.3.12 get `Temporal.ZonedDateTime.prototype.minute` @@ -690,7 +687,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.minute /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/minute /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.minute - fn get_minute(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_minute(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -699,10 +696,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .minute_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.minute()?.into()) } /// 6.3.13 get `Temporal.ZonedDateTime.prototype.second` @@ -716,7 +710,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.second /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/second /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.second - fn get_second(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_second(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -725,10 +719,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .second_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.second()?.into()) } /// 6.3.14 get `Temporal.ZonedDateTime.prototype.millisecond` @@ -742,7 +733,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.millisecond /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/millisecond /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.millisecond - fn get_millisecond(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_millisecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -751,10 +742,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .millisecond_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.millisecond()?.into()) } /// 6.3.15 get `Temporal.ZonedDateTime.prototype.microsecond` @@ -768,7 +756,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.microsecond /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/microsecond /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.microsecond - fn get_microsecond(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_microsecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -777,10 +765,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .microsecond_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.microsecond()?.into()) } /// 6.3.16 get `Temporal.ZonedDateTime.prototype.nanosecond` @@ -794,7 +779,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.nanosecond /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/nanosecond /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.nanosecond - fn get_nanosecond(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_nanosecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -803,10 +788,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .nanosecond_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.nanosecond()?.into()) } /// 6.3.17 get `Temporal.ZonedDateTime.prototype.epochMilliseconds` @@ -866,7 +848,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofweek /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/dayOfWeek /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.day_of_week - fn get_day_of_week(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_day_of_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -875,10 +857,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .day_of_week_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.day_of_week()?.into()) } /// 6.3.20 get `Temporal.ZonedDateTime.prototype.dayOfYear` @@ -892,7 +871,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofyear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/dayOfYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.day_of_year - fn get_day_of_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_day_of_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -901,10 +880,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .day_of_year_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.day_of_year()?.into()) } /// 6.3.21 get `Temporal.ZonedDateTime.prototype.weekOfYear` @@ -918,7 +894,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.weekofyear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/weekOfYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.week_of_year - fn get_week_of_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_week_of_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -927,10 +903,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .week_of_year_with_provider(context.tz_provider())? - .into_or_undefined()) + Ok(zdt.inner.week_of_year()?.into_or_undefined()) } /// 6.3.22 get `Temporal.ZonedDateTime.prototype.yearOfWeek` @@ -944,7 +917,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.yearofweek /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/yearOfWeek /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.year_of_week - fn get_year_of_week(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_year_of_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -953,10 +926,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .year_of_week_with_provider(context.tz_provider())? - .into_or_undefined()) + Ok(zdt.inner.year_of_week()?.into_or_undefined()) } /// 6.3.23 get `Temporal.ZonedDateTime.prototype.hoursInDay` @@ -996,7 +966,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinweek /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/daysInWeek /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.days_in_week - fn get_days_in_week(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_days_in_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1005,10 +975,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .days_in_week_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.days_in_week()?.into()) } /// 6.3.25 get `Temporal.ZonedDateTime.prototype.daysInMonth` @@ -1022,11 +989,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinmonth /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/daysInMonth /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.days_in_month - fn get_days_in_month( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + fn get_days_in_month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1035,10 +998,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .days_in_month_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.days_in_month()?.into()) } /// 6.3.26 get `Temporal.ZonedDateTime.prototype.daysInYear` @@ -1052,7 +1012,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinyear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/daysInYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.days_in_year - fn get_days_in_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_days_in_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1061,10 +1021,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .days_in_year_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.days_in_year()?.into()) } /// 6.3.27 get `Temporal.ZonedDateTime.prototype.monthsInYear` @@ -1078,11 +1035,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthsinyear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/monthsInYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.months_in_year - fn get_months_in_year( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + fn get_months_in_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1091,10 +1044,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .months_in_year_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.months_in_year()?.into()) } /// 6.3.28 get `Temporal.ZonedDateTime.prototype.inLeapYear` @@ -1108,7 +1058,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.inleapyear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/inLeapYear /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.in_leap_year - fn get_in_leap_year(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_in_leap_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1117,10 +1067,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .in_leap_year_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.in_leap_year()?.into()) } /// 6.3.29 get Temporal.ZonedDateTime.prototype.offsetNanoseconds @@ -1134,11 +1081,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/offsetNanoseconds /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.offset_nanoseconds - fn get_offset_nanoseconds( - this: &JsValue, - _: &[JsValue], - context: &mut Context, - ) -> JsResult { + fn get_offset_nanoseconds(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1147,10 +1090,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(zdt - .inner - .offset_nanoseconds_with_provider(context.tz_provider())? - .into()) + Ok(zdt.inner.offset_nanoseconds().into()) } /// 6.3.30 get Temporal.ZonedDateTime.prototype.offset @@ -1164,7 +1104,7 @@ impl ZonedDateTime { /// [spec]: https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offset /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/offset /// [temporal_rs-docs]: https://docs.rs/temporal_rs/latest/temporal_rs/struct.ZonedDateTime.html#method.offset - fn get_offset(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { + fn get_offset(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let object = this.as_object(); let zdt = object .as_ref() @@ -1173,7 +1113,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - Ok(JsString::from(zdt.inner.offset_with_provider(context.tz_provider())?).into()) + Ok(JsString::from(zdt.inner.offset()).into()) } } @@ -1347,7 +1287,9 @@ impl ZonedDateTime { let timezone = to_temporal_timezone_identifier(args.get_or_undefined(0), context)?; - let inner = zdt.inner.with_timezone(timezone)?; + let inner = zdt + .inner + .with_timezone_with_provider(timezone, context.tz_provider())?; create_temporal_zoneddatetime(inner, None, context).map(Into::into) } @@ -1873,9 +1815,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - let inner = zdt - .inner - .to_plain_date_with_provider(context.tz_provider())?; + let inner = zdt.inner.to_plain_date()?; create_temporal_date(inner, None, context).map(Into::into) } @@ -1899,9 +1839,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - let new = zdt - .inner - .to_plain_time_with_provider(context.tz_provider())?; + let new = zdt.inner.to_plain_time()?; create_temporal_time(new, None, context).map(Into::into) } @@ -1929,9 +1867,7 @@ impl ZonedDateTime { JsNativeError::typ().with_message("the this object must be a ZonedDateTime object.") })?; - let new = zdt - .inner - .to_plain_datetime_with_provider(context.tz_provider())?; + let new = zdt.inner.to_plain_datetime()?; create_temporal_datetime(new, None, context).map(Into::into) } }