RepoJournal
Elixir & Phoenix

Elixir & Phoenix

Elixir, Phoenix, LiveView, and Ecto - the BEAM web stack

Keep up with Elixir & Phoenix in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.

One email a day. Unsubscribe in one click.

Pick a date

Topics: Elixir & Phoenix Full archive →

The Wire · Showcase

ELIXIR FIXES TIME MATH BUG THAT ROUNDS THE WRONG WAY

By RepoJournal · Filed · About Elixir & Phoenix

NaiveDateTime.diff/3 has been silently rounding elapsed time up instead of down, breaking its documented contract and potentially causing logic errors in any code relying on time-based calculations.

The culprit: NaiveDateTime.diff/3 was truncating each operand separately before subtracting, computing floor(t1) - floor(t2) instead of floor(t1 - t2) [1]. When the subtrahend's fractional seconds exceeded the minuend's, this flipped the rounding direction entirely. An elapsed span of 86399.5 seconds (less than one day) incorrectly returned 1 for :day. This fix restores the documented guarantee that fractional results are truncated, not rounded up. Meanwhile, Duration.from_iso8601/1 was accepting malformed ISO 8601 strings with duplicate S markers for seconds [2], a parsing bug now corrected. On the spec side, Registry.lock/3 gains its missing type signature [3], and List specs are tightened to match their actual input handling [4]. These are the kind of quiet correctness fixes that ship before someone's calendar math breaks in production.

One email a day. Unsubscribe in one click.

Action items

References

  1. [1] Fix `NaiveDateTime.diff/3` over-counting incomplete units ↗ elixir-lang/elixir
  2. [2] Fix Duration.from_iso8601/1 accepting duplicate S (secs) when fractional elixir-lang/elixir
  3. [3] Add spec to Registry.lock/3 (#15575) elixir-lang/elixir
  4. [4] Fix List specs that are broader than the inputs handled (#15571) elixir-lang/elixir

Quick answers

What shipped in Elixir & Phoenix on July 11, 2026?
NaiveDateTime.diff/3 has been silently rounding elapsed time up instead of down, breaking its documented contract and potentially causing logic errors in any code relying on time-based calculations. In total, 18 commits and 17 pull requests landed.
Who contributed to Elixir & Phoenix on July 11, 2026?
4 developers shipped this update, including Alexander Gubarev, nseaSeb, Łukasz Samson, and SteffenDE.
What were the notable Elixir & Phoenix updates?
Fix `NaiveDateTime.diff/3` over-counting incomplete units, Fix Duration.from_iso8601/1 accepting duplicate S (secs) when fractional, and Add spec to Registry.lock/3 (#15575).

More from Elixir & Phoenix

Daily updates, in your inbox

Follow Elixir & Phoenix

Keep up with Elixir & Phoenix in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.

or

One email a day. Unsubscribe in one click. Read a past issue →

Elsewhere on the wire

Want every project, not just this one?

We use privacy-friendly analytics (Google Analytics, IP-anonymized) to see which pages help readers. No ads, and we never sell your data. See our Privacy Policy.