From a214ead3c5298f115f68ee0693f8fd5af702d31d Mon Sep 17 00:00:00 2001 From: preciz Date: Sat, 25 Jul 2026 12:18:40 +0200 Subject: [PATCH] Remove redundant abs calls from Calendar.ISO The BCE guards establish the sign of both calculations, so compute their positive magnitudes directly. Assisted-by: Codex:GPT-5 --- lib/elixir/lib/calendar/iso.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elixir/lib/calendar/iso.ex b/lib/elixir/lib/calendar/iso.ex index d2c287da089..ddead222f83 100644 --- a/lib/elixir/lib/calendar/iso.ex +++ b/lib/elixir/lib/calendar/iso.ex @@ -1176,7 +1176,7 @@ defmodule Calendar.ISO do @doc since: "1.8.0" @spec year_of_era(year) :: {1..10_000, era} def year_of_era(year) when is_year_CE(year), do: {year, 1} - def year_of_era(year) when is_year_BCE(year), do: {abs(year) + 1, 0} + def year_of_era(year) when is_year_BCE(year), do: {1 - year, 0} @doc """ Calendar callback to compute the year and era from the @@ -1229,7 +1229,7 @@ defmodule Calendar.ISO do end def day_of_era(year, month, day) when is_year_BCE(year) do - day = abs(date_to_iso_days(year, month, day) - @iso_epoch) + day = @iso_epoch - date_to_iso_days(year, month, day) {day, 0} end