diff --git a/crates/oxide_builtins/src/temporal.rs b/crates/oxide_builtins/src/temporal.rs index e02cb12f..3edf2517 100644 --- a/crates/oxide_builtins/src/temporal.rs +++ b/crates/oxide_builtins/src/temporal.rs @@ -2961,6 +2961,21 @@ pub fn plain_date_time_compare(vm: &mut H, args: &[u8]) -> NativeResu })) } +/// `Temporal.PlainDateTime.prototype.equals(other)`:比较日期时间分量是否相等。 +pub fn plain_date_time_equals(vm: &mut H, args: &[u8]) -> NativeResult { + let (y, m, d, ns) = match plain_date_time_parts(vm, args) { + Ok(parts) => parts, + Err(e) => return NativeResult::Err(e), + }; + let other_val = if args.len() > 1 { vm.reg(args[1]) } else { JsValue::undefined() }; + let other = match plain_date_time_like_parts(vm, other_val, true) { + Ok(parts) => parts, + Err(e) => return NativeResult::Err(e), + }; + let equal = other.0 == y && other.1 == m && other.2 == d && other.3 as u64 == ns as u64; + NativeResult::Ok(JsValue::bool(equal)) +} + fn plain_date_time_parts(vm: &mut H, args: &[u8]) -> Result<(i32, u32, u32, f64), JsValue> { let ptr = receiver_obj(vm, args)?; let obj = unsafe { &*ptr }; diff --git a/crates/oxide_vm/src/bindings/bind_temporal.rs b/crates/oxide_vm/src/bindings/bind_temporal.rs index 9d99cbf4..353ce23e 100644 --- a/crates/oxide_vm/src/bindings/bind_temporal.rs +++ b/crates/oxide_vm/src/bindings/bind_temporal.rs @@ -530,6 +530,11 @@ pub fn bind_temporal(core: &Arc, session: &KernelSession, global: &m oxide_builtins::temporal::plain_date_time_since:: as *const (), 1, ), + ( + "equals", + oxide_builtins::temporal::plain_date_time_equals:: as *const (), + 1, + ), ], ); bind_well_known_data_property(