【发布时间】:2018-04-04 18:59:37
【问题描述】:
我的目标是找出现在与某些提供的 date_time 之间的小时数差异。我正在尝试这样做:
pry(1)> dt1
#DateTime<2017-10-24 05:12:46.000000Z>
pry(2)> Ecto.DateTime.to_erl(dt1)
** (FunctionClauseError) no function clause matching in Ecto.DateTime.to_erl/1
The following arguments were given to Ecto.DateTime.to_erl/1:
# 1
#DateTime<2017-10-24 05:12:46.000000Z>
Attempted function clauses (showing 1 out of 1):
def to_erl(%Ecto.DateTime{year: year, month: month, day: day, hour: hour, min: min, sec: sec})
(ecto) lib/ecto/date_time.ex:608: Ecto.DateTime.to_erl/1
# ............
如何解决这个问题? 或者有没有更好的方法来实现我的目标?
注意,我不使用 timex,也不会使用它,也不会使用任何第三方库。只有 Elixir/Erlang/Phoenix 内置的。
【问题讨论】: