style: 自动格式化

This commit is contained in:
2026-10-16 01:58:42 +00:00
parent 6dbf6be3a8
commit e11c5a0174
4 changed files with 11 additions and 20 deletions
+2 -5
View File
@@ -987,9 +987,7 @@ pub(crate) fn parse_time_zone_string(value: &str) -> Option<String> {
/// # 边界与前提 /// # 边界与前提
/// - 字符串接受面与规范一致:UTC/Z、整数分钟偏移串、IANA 区名、带注解与尾偏移的 /// - 字符串接受面与规范一致:UTC/Z、整数分钟偏移串、IANA 区名、带注解与尾偏移的
/// 日期时间串;亚分钟偏移拒绝。 /// 日期时间串;亚分钟偏移拒绝。
pub(crate) fn to_temporal_time_zone_identifier<H: VmHost>( pub(crate) fn to_temporal_time_zone_identifier<H: VmHost>(vm: &mut H, value: JsValue) -> Result<String, JsValue> {
vm: &mut H, value: JsValue,
) -> Result<String, JsValue> {
if value.is_object() { if value.is_object() {
let ptr = value.as_js_object_ptr(); let ptr = value.as_js_object_ptr();
if !ptr.is_null() { if !ptr.is_null() {
@@ -1005,8 +1003,7 @@ pub(crate) fn to_temporal_time_zone_identifier<H: VmHost>(
} }
if value.is_string() { if value.is_string() {
let input = to_string(value); let input = to_string(value);
return parse_time_zone_string(&input) return parse_time_zone_string(&input).ok_or_else(|| crate::error::create_range_error(vm, "invalid time zone"));
.ok_or_else(|| crate::error::create_range_error(vm, "invalid time zone"));
} }
Err(crate::error::create_type_error(vm, "invalid time zone")) Err(crate::error::create_type_error(vm, "invalid time zone"))
} }
@@ -717,8 +717,8 @@ pub fn plain_date_to_zoned_datetime<H: VmHost>(vm: &mut H, args: &[u8]) -> Nativ
let time_zone_id = native_try!(to_temporal_time_zone_identifier(vm, time_zone_like)); let time_zone_id = native_try!(to_temporal_time_zone_identifier(vm, time_zone_like));
let time_ns = native_try!(plain_time_like_ns(vm, temporal_time)); let time_ns = native_try!(plain_time_like_ns(vm, temporal_time));
if temporal_time.is_undefined() { if temporal_time.is_undefined() {
let epoch = get_start_of_day_epoch_ns(&time_zone_id, year, month, day) let epoch =
.map_err(|error| map_add_zoned_error(vm, error)); get_start_of_day_epoch_ns(&time_zone_id, year, month, day).map_err(|error| map_add_zoned_error(vm, error));
let epoch_ns = native_try!(epoch); let epoch_ns = native_try!(epoch);
return make_zoned_date_time(vm, epoch_ns, &time_zone_id, &calendar); return make_zoned_date_time(vm, epoch_ns, &time_zone_id, &calendar);
} }
@@ -6,6 +6,9 @@ use oxide_types::object::JsObject;
use oxide_types::value::JsValue; use oxide_types::value::JsValue;
use super::common::native_try; use super::common::native_try;
use super::zoned_date_time::{
disambiguate_possible_epoch_nanoseconds, get_possible_epoch_nanoseconds, map_add_zoned_error,
};
use super::{ use super::{
civil_from_days, days_from_civil, days_in_month, days_in_month_iso, difference_core, duration_component_integer, civil_from_days, days_from_civil, days_in_month, days_in_month_iso, difference_core, duration_component_integer,
duration_like_values, ensure_plain_date_time, format_iso_year, get_calendar_id, get_double_prop, duration_like_values, ensure_plain_date_time, format_iso_year, get_calendar_id, get_double_prop,
@@ -18,9 +21,6 @@ use super::{
temporal_overflow, to_temporal_time_zone_identifier, valid_iso_date, valid_plain_date_time_range, valid_plain_time, temporal_overflow, to_temporal_time_zone_identifier, valid_iso_date, valid_plain_date_time_range, valid_plain_time,
zoned_date_time_plain_parts, DateTimeParts, FractionalSecondDigitsInput, IsoDateTime, zoned_date_time_plain_parts, DateTimeParts, FractionalSecondDigitsInput, IsoDateTime,
}; };
use super::zoned_date_time::{
disambiguate_possible_epoch_nanoseconds, get_possible_epoch_nanoseconds, map_add_zoned_error,
};
// ───────────────────── PlainDateTime 基础方法 ───────────────────── // ───────────────────── PlainDateTime 基础方法 ─────────────────────
/// `Temporal.PlainDateTime` 构造器:保存 ISO 日期与午夜后纳秒。 /// `Temporal.PlainDateTime` 构造器:保存 ISO 日期与午夜后纳秒。
@@ -26,8 +26,8 @@ use super::instant::{
round_instant_ns, InstantRoundingMode, round_instant_ns, InstantRoundingMode,
}; };
use super::time_zone::{ use super::time_zone::{
named_zone_possible_epoch_ns, tz_gap_offsets, tz_gap_transition_epoch, tz_next_transition, named_zone_possible_epoch_ns, tz_gap_offsets, tz_gap_transition_epoch, tz_next_transition, tz_prev_transition,
tz_prev_transition, zone_offset_seconds, zone_offset_seconds,
}; };
use super::{ use super::{
days_in_month_iso, duration_like_values, duration_time_only_nanoseconds, is_leap_year_iso, make_duration, days_in_month_iso, duration_like_values, duration_time_only_nanoseconds, is_leap_year_iso, make_duration,
@@ -1662,18 +1662,12 @@ pub fn zoned_date_time_get_time_zone_transition<H: VmHost>(vm: &mut H, args: &[u
} else if direction_param.is_object() { } else if direction_param.is_object() {
let ptr = direction_param.as_js_object_ptr(); let ptr = direction_param.as_js_object_ptr();
if ptr.is_null() { if ptr.is_null() {
return NativeResult::Err(crate::error::create_type_error( return NativeResult::Err(crate::error::create_type_error(vm, "direction must be a string or an object"));
vm,
"direction must be a string or an object",
));
} }
let options = unsafe { &*ptr }; let options = unsafe { &*ptr };
native_try!(temporal_option_value(vm, options, direction_param, "direction")) native_try!(temporal_option_value(vm, options, direction_param, "direction"))
} else { } else {
return NativeResult::Err(crate::error::create_type_error( return NativeResult::Err(crate::error::create_type_error(vm, "direction must be a string or an object"));
vm,
"direction must be a string or an object",
));
}; };
let direction = if direction_raw.is_undefined() { let direction = if direction_raw.is_undefined() {
return NativeResult::Err(crate::error::create_range_error(vm, "direction is required")); return NativeResult::Err(crate::error::create_range_error(vm, "direction is required"));