ReviewOS

zig-utils/zig-js

ABI: implement private Date parsing and ISO formatting

#187
Closed chris opened this 9 days ago ·
9 days ago

Parents: #163, #164 Depends on: #179, #180

Implement the shared private Date parsing, UTC extraction, and ISO buffer boundary.

Acceptance:

  • Export JSC__JSValue__dateInstanceFromNullTerminatedString, JSC__JSValue__getUTCTimestamp, JSC__JSValue__toISOString, and JSC__JSValue__DateNowISOString.
  • Parse the complete NUL-terminated byte string using the engine Date parser, create a fresh selected-realm Date cell, and preserve invalid parses as a Date with a NaN internal value.
  • Return the Date internal UTC epoch-millisecond value from getUTCTimestamp; return NaN for non-Date, invalid, or foreign-VM values.
  • Write exact ECMAScript UTC ISO output (24-byte ordinary years, 27-byte extended years) without a terminator and return the byte count; return -1 without modifying the caller buffer for non-Date/non-finite input.
  • Make DateNowISOString use the realm clock and the same 28-byte writer contract.
  • Document the pinned-source defect: Bun's Zig declaration for DateNowISOString is (*JSGlobalObject, f64) JSValue, but its wrapper and C++ implementation use (*JSGlobalObject, *[28]u8) c_int; implement and test the executable wrapper/C++ contract.
  • Document that the pinned Bun source declares but does not define getUTCTimestamp; test the coherent UTC internal-time contract rather than claiming a matched C++ body.
  • Cover epoch, fractional truncation, pre-epoch milliseconds, leap dates, offsets, extended years, invalid input, non-Date values, same-VM sibling realms, foreign VMs, and failure-atomic buffers.
  • Refresh Home/Bun inventories and README/API documentation without changing public/extension counts.
9 days ago

Implemented and documented on main in 23519ef and c8e801b.

Evidence:

  • zig build test-home-private-abi: 57/57 private value symbols linked; runtime matrix passed.
  • zig build test -Dtest-filter=Date: 10/10 focused Date tests passed with zero leaks.
  • Home private inventory: 59/432 implemented, 373 pending.
  • Bun core private inventory: 59/422 implemented, 363 pending.
  • Public/extension accounting remains 117/19.
  • Batched Home, Bun, and public C-API audits all pass.
  • README and ABI/API/Home integration docs describe the writer ABI discrepancy and the missing pinned Bun getUTCTimestamp definition.

Sign in to comment on this issue.