From 64a5da45c0fe382dd772a9fc46dd1e720db97de8 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Wed, 12 Aug 2026 10:47:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20PlainDate=20equals/compare=20=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E5=8F=82=E6=95=B0=E7=BB=8F=20date=5Flike=5Fy?= =?UTF-8?q?md=20=E8=BD=AC=E6=8D=A2=E5=B9=B6=E5=81=9A=20ISO=20=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_builtins/src/temporal.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/crates/oxide_builtins/src/temporal.rs b/crates/oxide_builtins/src/temporal.rs index 2b39c3b8..bc890201 100644 --- a/crates/oxide_builtins/src/temporal.rs +++ b/crates/oxide_builtins/src/temporal.rs @@ -4118,10 +4118,11 @@ pub fn plain_date_equals(vm: &mut H, args: &[u8]) -> NativeResult { Err(e) => return NativeResult::Err(e), }; let other_val = if args.len() > 1 { vm.reg(args[1]) } else { JsValue::undefined() }; - let equal = match object_ymd(vm, other_val) { - Some((oy, om, od)) => oy as f64 == y && om as f64 == m && od as f64 == d, - None => false, + let other = match date_like_ymd(vm, other_val) { + Ok(x) => x, + Err(e) => return NativeResult::Err(e), }; + let equal = other.0 as f64 == y && other.1 as f64 == m && other.2 as f64 == d; NativeResult::Ok(JsValue::bool(equal)) } @@ -4129,17 +4130,13 @@ pub fn plain_date_equals(vm: &mut H, args: &[u8]) -> NativeResult { pub fn plain_date_compare(vm: &mut H, args: &[u8]) -> NativeResult { let a_val = if args.len() > 1 { vm.reg(args[1]) } else { JsValue::undefined() }; let b_val = if args.len() > 2 { vm.reg(args[2]) } else { JsValue::undefined() }; - let a = match object_ymd(vm, a_val) { - Some(x) => x, - None => { - return NativeResult::Err(crate::error::create_type_error(vm, "cannot convert to PlainDate")); - } + let a = match date_like_ymd(vm, a_val) { + Ok(x) => x, + Err(e) => return NativeResult::Err(e), }; - let b = match object_ymd(vm, b_val) { - Some(x) => x, - None => { - return NativeResult::Err(crate::error::create_type_error(vm, "cannot convert to PlainDate")); - } + let b = match date_like_ymd(vm, b_val) { + Ok(x) => x, + Err(e) => return NativeResult::Err(e), }; let cmp = (a.0, a.1, a.2).cmp(&(b.0, b.1, b.2)); NativeResult::Ok(JsValue::float(match cmp {