如何在 Elixir 中使用 NaiveDateTime.local_now
How to use NaiveDateTime.local_now in Elixir
我正在使用 NaiveDateTime.local_now/1
来记录项目在我的数据库中的保存时间和访问时间。当我 运行 在我的机器上使用命令 mix compile --warnings-as-errors --force
发出警告时,它没有记录任何错误,但是当我 运行 它在我们的 gitlab 运行ner 上时,管道因错误而失败
warning: function NaiveDateTime.local_now/0 is undefined or private
这是我的使用方法NaiveDateTime.local_now() |> NaiveDateTime.add(900)
有什么见解吗?我正在使用 image: elixir:1.7.4-alpine
作为我的 Elixir 图像
NaiveDateTime.local_now/1
exists since v1.10.0
as shown in the top right corner of the window in the documentation I linked and which might be seen by navigating to sources of v1.7.4
.
绝对没有理由在生产中保留 v1.7.4
,elixir is perfectly backward-compatible. Upgrade your image, or, if it is impossible, backport the function 到您自己的模块并改为调用它。
defmodule MyHelpers do
def local_now(Calendar.ISO) do
{{year, month, day}, {hour, minute, second}} =
:erlang.localtime()
{:ok, ndt} =
NaiveDateTime.new(year, month, day, hour, minute, second)
ndt
end
end
我正在使用 NaiveDateTime.local_now/1
来记录项目在我的数据库中的保存时间和访问时间。当我 运行 在我的机器上使用命令 mix compile --warnings-as-errors --force
发出警告时,它没有记录任何错误,但是当我 运行 它在我们的 gitlab 运行ner 上时,管道因错误而失败
warning: function NaiveDateTime.local_now/0 is undefined or private
这是我的使用方法NaiveDateTime.local_now() |> NaiveDateTime.add(900)
有什么见解吗?我正在使用 image: elixir:1.7.4-alpine
作为我的 Elixir 图像
NaiveDateTime.local_now/1
exists since v1.10.0
as shown in the top right corner of the window in the documentation I linked and which might be seen by navigating to sources of v1.7.4
.
绝对没有理由在生产中保留 v1.7.4
,elixir is perfectly backward-compatible. Upgrade your image, or, if it is impossible, backport the function 到您自己的模块并改为调用它。
defmodule MyHelpers do
def local_now(Calendar.ISO) do
{{year, month, day}, {hour, minute, second}} =
:erlang.localtime()
{:ok, ndt} =
NaiveDateTime.new(year, month, day, hour, minute, second)
ndt
end
end