Skip to content

Rust refactor: collapse 3 hand-rolled civil-date implementations onto the time crate #331

Description

@willwashburn

Context

The same Howard Hinnant civil-date algorithm is hand-rolled three times in three files:

  1. crates/relayburn-sdk/src/ledger/writer.rs:26 now_iso — though the function name is misleading, see #(forthcoming bug-bundle issue).
  2. crates/relayburn-sdk/src/ingest/pending_stamps.rs:477-489 format_iso_8601, :491-530 parse_iso_ms, :638+ civil_from_unix_seconds / unix_seconds_from_civil.
  3. crates/relayburn-sdk/src/query_verbs.rs:117-142 format_iso_z / days_to_ymd.

Plus a fourth ~240-line copy in crates/relayburn-cli/src/commands/compare.rs:258-495 — covered separately as "switch compare.rs to SDK normalize_since".

Proposed fix

Add time = "0.3" to relayburn-sdk/Cargo.toml (zero-runtime, no feature gates needed for the formatting we use). Replace all three implementations with OffsetDateTime / Date operations. The functions become 1-2 liners.

Verify byte-identical output against the existing golden tests + the conformance gate. The TS sibling uses ISO-8601 / millisecond precision; time::format_description::well_known::Iso8601 matches.

Estimated removal: ~250 LOC.

Out of scope

  • Whole chrono adoption — time is sufficient for what we need and has fewer transitive deps.
  • Touching compare.rs — that's covered by the separate normalize_since migration issue.

References

  • Ingest+ledger review notes from the May 2026 Rust review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions