Skip to content

Commit 34f58ff

Browse files
committed
Use shift day for inlfate_by_month
1 parent 46ff55f commit 34f58ff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/recurring_events/by_pump.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ defmodule RecurringEvents.ByPump do
104104
defp inflate_by_month(date, %{by_month: months}) do
105105
Stream.map(months, fn month ->
106106
day = @date_helper.last_day_of_the_month(%{date | month: month})
107-
%{date | month: month, day: min(day, date.day)}
107+
month_shift = month - date.month
108+
new_date = date |> @date_helper.shift_date(month_shift, :months)
109+
day_shift = min(day, date.day) - new_date.day
110+
new_date |> @date_helper.shift_date(day_shift, :days)
108111
end)
109112
end
110113

0 commit comments

Comments
 (0)