Repository navigation
Remove Timex dependency in favor of Elixir stdlib - #60
Conversation
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]>
| app: :sched_ex, | ||
| version: @version, | ||
| elixir: "~> 1.9", | ||
| elixir: "~> 1.11", |
There was a problem hiding this comment.
Elixir 1.11 was released in 2020 and added support for time zone databases
| assert adjusted_time == expected_time_for_adjust | ||
| end | ||
|
|
||
| test "adjusts non-existent times when midnight itself is in the DST gap", |
There was a problem hiding this comment.
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
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]>
|
Looks like some linting errors? |
|
@mtrudel Ah, I missed that. Lint job is now passing: https://github.com/SchedEx/SchedEx/actions/runs/30380331772/job/90346313165?pr=60 |
|
Still failing CI but the tests on this project are SUPER flaky and the errors look transient. |
|
Released as 1.2.0 |
|
Great, thank you! I was taking a look at fixing the flaky tests too but it doesn't seem super straightforward. |
#60 drops timex in favor of DateTime, but doesn't update the default "UTC" timezone to "Etc/UTC" (ref: https://elixir.hexdocs.pm/DateTime.html#now/2)
Remove timex by replacing all Timex calls with Elixir stdlib equivalents. Minimum Elixir version needed to be bumped to
~> 1.11for 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