Skip to content

Remove Timex dependency in favor of Elixir stdlib - #60

Merged
mtrudel merged 4 commits into
SchedEx:mainfrom
axelson:remove-timex
Jul 29, 2026
Merged

mtrudel merged 4 commits into
SchedEx:mainfrom
axelson:remove-timex

Conversation

@axelson

@axelson axelson commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Remove timex by replacing all Timex calls with Elixir stdlib equivalents. Minimum Elixir version needed to be bumped to ~> 1.11 for timezone database support.

Fixes #11

Note: Timex is no longer well maintained and hasn't upgraded support for major dependencies like gettext bitwalker/timex#782

Note: I used claude for this but the changes are mostly mechanical and I've reviewed the code and used it in a personal project (although that project doesn't exercise all of SchedEx)

Note: CI is failing in this PR but also on main

Replace all Timex calls with Elixir stdlib equivalents (DateTime.add,
DateTime.from_naive, DateTime.now!, etc.), eliminating the Timex
dependency entirely. This gives UTC-only users a much lighter dependency
tree. Users who need non-UTC timezone support must configure a
Calendar.TimeZoneDatabase (e.g. tzdata) in their application.

The DST gap handling is simplified by using DateTime.from_naive's
{:gap, _, just_after} tuple instead of the previous Tzdata.periods_for_time
internal API call. Minimum Elixir version bumped to ~> 1.11 for timezone
database support.

Closes SchedEx#11

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread mix.exs
app: :sched_ex,
version: @version,
elixir: "~> 1.9",
elixir: "~> 1.11",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elixir 1.11 was released in 2020 and added support for time zone databases

Comment thread test/sched_ex_test.exs
assert adjusted_time == expected_time_for_adjust
end

test "adjusts non-existent times when midnight itself is in the DST gap",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test and bug fix are from a second commit that can be easily dropped from the PR (arguably I shouldn't have included it), but it is a bug in timex currently that only affects a few time zones

axelson and others added 2 commits July 25, 2026 19:51
Handle all three DateTime.from_naive/2 return values ({:ok, _},
{:gap, _, _}, {:ambiguous, _, _}) when converting midnight to a
DateTime. Previously this would crash with MatchError for timezones
like America/Santiago where DST transitions occur at midnight.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mtrudel

mtrudel commented Jul 27, 2026

Copy link
Copy Markdown
Member

Looks like some linting errors?

@axelson

axelson commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@mtrudel

mtrudel commented Jul 29, 2026

Copy link
Copy Markdown
Member

Still failing CI but the tests on this project are SUPER flaky and the errors look transient.

@mtrudel
mtrudel merged commit 237e83f into SchedEx:main Jul 29, 2026
8 of 20 checks passed
@mtrudel

mtrudel commented Jul 29, 2026

Copy link
Copy Markdown
Member

Released as 1.2.0

@axelson
axelson deleted the remove-timex branch July 29, 2026 03:13
@axelson

axelson commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Great, thank you! I was taking a look at fixing the flaky tests too but it doesn't seem super straightforward.

mtrudel pushed a commit that referenced this pull request Aug 18, 2026
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.

Timex as an optional dependency?

2 participants