Skip to content

Commit

Permalink
Truncate naivedatetime to :second
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmicahcooper committed Oct 10, 2019
1 parent f066dfc commit 78a3446
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ecto_factory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ defmodule EctoFactory do
def gen(:date), do: Date.utc_today()
def gen(:time), do: Time.utc_now()
def gen(:time_usec), do: gen(:time)
def gen(:naive_datetime), do: NaiveDateTime.utc_now()

def gen(:naive_datetime) do
NaiveDateTime.utc_now()
|> NaiveDateTime.truncate(:second)
end

def gen(:naive_datetime_usec), do: gen(:naive_datetime)
def gen(:utc_datetime), do: DateTime.utc_now()
def gen(:utc_datetime_usec), do: gen(:utc_datetime)
Expand Down

0 comments on commit 78a3446

Please sign in to comment.