docs: 改写 Temporal 共享与差量层注释

- common.rs 模块头删「最小实现子集」,补 Duration 槽位并逐类型列出 prop 布局;
  reject_partial_object_with_calendar_or_time_zone 文档改中文语义句并移操作名入括注
- instant.rs round_instant_ns 文档改「语义在前 + 操作名括注」,补 increment/溢出边界
- duration.rs duration_compare 步骤 4 与相等短路注释删除测试名,写明日历单位必须依赖相对点
- difference.rs 改写差值设置解析两处文档(去箭头电报体与裸操作名)、
  nudge/bubble 两处函数文档、进位边界范围校验说明,统一 Nudge 族为中文语义加括注
This commit is contained in:
2026-09-17 12:59:34 +00:00
parent d22c5dfcdb
commit 5a0fc98aa1
4 changed files with 64 additions and 31 deletions
@@ -822,7 +822,7 @@ fn duration_apply_to_relative<H: VmHost>(
/// 1. one/two 各自 duration_like_values 归一(读序 one → two → options)。
/// 2. options.relativeTo 经 duration_relative_to_date 归一(含 ZDT/Instant/bag 分支)。
/// 3. 无 relativeTo 且无日历单位:按 duration_time_nanoseconds 直接比大小(fast path)。
/// 4. 无 relativeTo 但含日历单位:RangeError(calendar-possibly-required 语义)。
/// 4. 无 relativeTo 但含日历单位:抛 RangeError,日历单位无法脱离具体相对点折算。
/// 5. 有 relativeTo:每个 duration 应用相对点得 (date, time),先比日期再比时间(字典序)。
///
/// # 边界与前提
@@ -833,7 +833,8 @@ pub fn duration_compare<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let two_val = if args.len() > 2 { vm.reg(args[2]) } else { JsValue::undefined() };
let one = native_try!(duration_like_values(vm, one_val));
let two = native_try!(duration_like_values(vm, two_val));
// 全分量相等直接返回 0(含日历单位时也无需 relativeTo,对齐 instances-identical)。
// 十个分量逐一相等时直接返回 0:相等时长无论是否含日历单位,应用任意相对点结果都相同,
// 无需读取 options.relativeTo。
if one == two {
return NativeResult::Ok(JsValue::int(0));
}