defmodule TestContract do
use Drops.Contract
schema do
%{required(:test) => from(:integer) |> type(:date_time)}
end
end
TestContract.conform(%{test: 1695277470})
# {:ok, %{test: ~U[2023-09-21 06:24:30Z]}}
Providing time unit as an argument for the casting function:
defmodule TestContract do
use Drops.Contract
schema do
%{required(:test) => from(:integer, [:millisecond]) |> type(:date_time)}
end
end
TestContract.conform(%{test: 1695277723355})
# {:ok, %{test: ~U[2023-09-21 06:28:43.355Z]}}
Using the default
:second
unit:Providing time unit as an argument for the casting function:
Closes #10