Hope to get some advice:
defmodule MyWeb.PageView do
use MyWeb, :view
def current_timeinterval do
{:ok, first_day} =
Timex.beginning_of_month(Timex.now(Timex.Timezone.local()))
|> Timex.format("{D} {Mfull} {YYYY}")
{:ok, last_day} =
Timex.end_of_month(Timex.now(Timex.Timezone.local()))
|> Timex.format("{D} {Mfull} {YYYY}")
"#{first_day} - #{last_day}"
end
end
My intention is to embed the output of this current_timeinterval() function in a EEx template and it will result in the value “1 December 2020 - 30 December 2020” as of now being displayed on the page, new.html
However Dialyzer generates this error:
“Function new.html/1 has no local return”
“Function current_timeinterval/0 has no local return.”
followed by
"message": "The function call will not succeed.\n\nTimex.now(\n {:error, _}\n | %{\n :__struct__ => Timex.AmbiguousTimezoneInfo | Timex.TimezoneInfo,\n ..."
Any thoughts on what I am probably doing wrong? Many thanks.