From 9a328ece6ecfa880088d16933ddb16969695774f Mon Sep 17 00:00:00 2001 From: Matthew Lehner Date: Sat, 11 Apr 2026 11:43:16 -0700 Subject: [PATCH 1/3] Replace Timex.weekday/1 with Date.day_of_week/1 Both functions return 1 (Monday) through 7 (Sunday) by default, making this a direct 1:1 replacement with no behavior change. --- lib/ical/recurrence.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ical/recurrence.ex b/lib/ical/recurrence.ex index 243b8b1..416460b 100644 --- a/lib/ical/recurrence.ex +++ b/lib/ical/recurrence.ex @@ -323,7 +323,7 @@ defmodule ICal.Recurrence do |> Enum.map(fn {_offset, by_day} -> # TODO: support offsets other than the trivial case of 0 # determine the difference between the by_day and dtstart - day_offset_for_reference = Map.get(day_values, by_day) - Timex.weekday(component.dtstart) + day_offset_for_reference = Map.get(day_values, by_day) - Date.day_of_week(component.dtstart) shift(component, days: day_offset_for_reference) end) end From 818cf032524f0ee07385afce2ded07b50526fa32 Mon Sep 17 00:00:00 2001 From: Matthew Lehner Date: Sat, 11 Apr 2026 11:43:45 -0700 Subject: [PATCH 2/3] Replace Timex.shift/2 with Date.shift/2 and DateTime.shift/2 Remove Timex.AmbiguousDateTime handling since stdlib shift functions do not return ambiguous datetime structs. Pattern match on Date/DateTime to dispatch to the correct module. Update shift_opts to use singular unit names (day, month, year) as required by stdlib Duration, replacing Timex's plural convention (days, months, years). --- lib/ical/recurrence.ex | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/ical/recurrence.ex b/lib/ical/recurrence.ex index 416460b..9f74577 100644 --- a/lib/ical/recurrence.ex +++ b/lib/ical/recurrence.ex @@ -172,10 +172,10 @@ defmodule ICal.Recurrence do defp resolve_end_date(%DateTime{} = end_date, %Date{}), do: DateTime.to_date(end_date) - defp shift_opts(:daily, interval), do: [days: interval] - defp shift_opts(:weekly, interval), do: [days: interval * 7] - defp shift_opts(:monthly, interval), do: [months: interval] - defp shift_opts(:yearly, interval), do: [years: interval] + defp shift_opts(:daily, interval), do: [day: interval] + defp shift_opts(:weekly, interval), do: [week: interval] + defp shift_opts(:monthly, interval), do: [month: interval] + defp shift_opts(:yearly, interval), do: [year: interval] defp add_recurrences_until(original_event, references, until, shift_opts) do Stream.resource( @@ -277,15 +277,8 @@ defmodule ICal.Recurrence do }) end - defp shift_date(date, shift_opts) do - case Timex.shift(date, shift_opts) do - %Timex.AmbiguousDateTime{} = new_date -> - new_date.after - - new_date -> - new_date - end - end + defp shift_date(%Date{} = date, shift_opts), do: Date.shift(date, shift_opts) + defp shift_date(%DateTime{} = date, shift_opts), do: DateTime.shift(date, shift_opts) defp build_references_by_x_rules(by_x_rrules, component) when by_x_rrules == %{} do [component] @@ -324,7 +317,7 @@ defmodule ICal.Recurrence do # TODO: support offsets other than the trivial case of 0 # determine the difference between the by_day and dtstart day_offset_for_reference = Map.get(day_values, by_day) - Date.day_of_week(component.dtstart) - shift(component, days: day_offset_for_reference) + shift(component, day: day_offset_for_reference) end) end From fa8b712bc93e51ba6d4282d3a75951f853c54c68 Mon Sep 17 00:00:00 2001 From: Matthew Lehner Date: Sat, 11 Apr 2026 11:48:39 -0700 Subject: [PATCH 3/3] Replace Timex.to_date in doc examples with ~D sigils --- lib/ical/recurrence.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ical/recurrence.ex b/lib/ical/recurrence.ex index 9f74577..9c064cc 100644 --- a/lib/ical/recurrence.ex +++ b/lib/ical/recurrence.ex @@ -100,8 +100,8 @@ defmodule ICal.Recurrence do ## Examples - iex> dt = Timex.to_date({2016,8,13}) - iex> dt_end = Timex.to_date({2016, 8, 23}) + iex> dt = ~D[2016-08-13] + iex> dt_end = ~D[2016-08-23] iex> event = %ICal.Event{rrule: %ICal.Recurrence{frequency: :daily}, dtstart: dt, dtend: dt} iex> recurrences = ICal.Recurrence.stream(event)