Closed xingd closed 5 years ago
The following statements
~N[2019-05-31 23:00:00] |> Crontab.DateHelper.inc_month
returns ~N[2019-07-01 23:00:00].
~N[2019-07-01 23:00:00]
Two workaround, add fewer days:
def inc_month(%NaiveDateTime{day: day} = date) do days = date |> NaiveDateTime.to_date() |> Date.days_in_month() NaiveDateTime.add(date, (days + 1 - day) * 86_400, :second) end
or change function call order:
defp correct_date(:month, date, :increment), do: date |> DateHelper.beginning_of(:month) |> DateHelper.inc_month()
@xingd Thanks for the report. A fix has been published with v1.1.6.
v1.1.6
The following statements
returns
~N[2019-07-01 23:00:00]
.Two workaround, add fewer days:
or change function call order: