Skip to content

Feat/rust nif datetime poc#142

Open
lupodevelop wants to merge 2 commits into
arkemis:mainfrom
lupodevelop:feat/rust-nif-datetime-poc
Open

Feat/rust nif datetime poc#142
lupodevelop wants to merge 2 commits into
arkemis:mainfrom
lupodevelop:feat/rust-nif-datetime-poc

Conversation

@lupodevelop

Copy link
Copy Markdown

What

Replace Timex with the Elixir stdlib in Arke.Utils.DatetimeHandler, and move
ISO8601 parsing and month shifting to a Rust NIF (Arke.Native.DateParser).

  • parse_date / parse_time / parse_datetime, and month arithmetic for shift_* → NIF (chrono)
  • now / format / from_unix / after? / before? / struct normalization → stdlib
  • Timex dropped from deps

If the NIF isn't loaded, parsing and shifting fall back to pure Elixir, so
runtime behaviour is the same with or without the native lib.

Why

Timex pulled in tzdata (and its runtime auto-update) for what is mostly ISO
parsing and now. The stdlib covers all of it now. The NIF also does
calendar-correct month shifting, which the stdlib doesn't do on its own.

This is also the first Rust component: the build, cross-compiled release
binaries, fallback and tests are set up so future native pieces are cheap to add.

Breaking changes

  • format/2 now only supports ISO extended/basic, not arbitrary Timex format
    strings. Only {ISO:Basic:Z} and the default are used in this repo, so
    internal callers are unaffected.
  • Timex is gone. arke-server used it transitively through this lib (one dead
    or Timex.from_unix(...) branch in apple.ex). Companion PR

CI

CI will be red on this PR. For fork PRs GitHub runs the base branch workflows,
which don't have a Rust step yet, so the NIF won't compile. The Rust setup is in
this diff (ci.yml + native.yml + release.yml) and is green once on main.

Distribution

Binaries are built by release.yml on tag and published to the GitHub release;
rustler_precompiled downloads them so users don't need Rust.

Bootstrap: this version builds from source (force_build defaults true), so the
Rust toolchain is required to compile until the first tagged release exists.
After that release, commit the generated checksum and flip force_build to
false. From then on it's download-only, no Rust needed downstream.

Tests

mix test test/utils/datetime_handler_test.exs golden cases plus randomized
runs checking NIF output against the stdlib parser and against plain-Elixir
month math. cargo fmt/clippy/test run in native.yml.

@lupodevelop
lupodevelop requested a review from a team as a code owner June 4, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant