Hi,
I am struggling with dates and Ecto (3). My schema contains field(:matchdate, :utc_datetime)
.
In my app I build a datetime by
defp to_datetime(datetime_from_external_api) do
{:ok, new_datetime, 0} = DateTime.from_iso8601("#{year}-#{month}-#{day}T#{hour}:#{min}:00Z")
new_datetime
end
This I use in creating the changeset:
Ecto.Changeset.change(%{
...
matchdate: to_datetime(to_string(api_matchdate))
})
This is the error message I get:
** (BadArityError) #Function<1.129354666/1 in MyProgram.fixtures/1> with arity 1 called with 2 arguments (ecto.Changeset<action: nil, changes: %{away_goals: β3β, away_team_id: β3348β, home_goals: β0β, home_team_id: β534β, match_id: β63454β, match_round: β1β, matchdate: ~U[2019-07-07 09:30:00Z], season: β4β}, errors: , data: #MyProgram.Match<>, valid?: true>, )
(elixir) lib/enum.ex:1948: Enum.β-reduce/3-lists^foldl/2-0-β/3
The error message doesnβt tell me anything. Do I have to convert my DateTime somehow to utc_datetime?
Thanks