@@ -252,7 +252,7 @@ defmodule NaiveDateTime do
252252 Calendar . hour ( ) ,
253253 Calendar . minute ( ) ,
254254 Calendar . second ( ) ,
255- Calendar . microsecond ( ) | non_neg_integer ,
255+ Calendar . microsecond ( ) | non_neg_integer ( ) ,
256256 Calendar . calendar ( )
257257 ) :: { :ok , t } | { :error , atom }
258258 def new ( year , month , day , hour , minute , second , microsecond \\ { 0 , 0 } , calendar \\ Calendar.ISO )
@@ -317,7 +317,7 @@ defmodule NaiveDateTime do
317317 Calendar . hour ( ) ,
318318 Calendar . minute ( ) ,
319319 Calendar . second ( ) ,
320- Calendar . microsecond ( ) | non_neg_integer ,
320+ Calendar . microsecond ( ) | non_neg_integer ( ) ,
321321 Calendar . calendar ( )
322322 ) :: t
323323 def new! (
@@ -993,6 +993,8 @@ defmodule NaiveDateTime do
993993
994994 iex> NaiveDateTime.from_erl({{2000, 1, 1}, {13, 30, 15}})
995995 {:ok, ~N[2000-01-01 13:30:15]}
996+ iex> NaiveDateTime.from_erl({{2000, 1, 1}, {13, 30, 15}}, 5000)
997+ {:ok, ~N[2000-01-01 13:30:15.005000]}
996998 iex> NaiveDateTime.from_erl({{2000, 1, 1}, {13, 30, 15}}, {5000, 3})
997999 {:ok, ~N[2000-01-01 13:30:15.005]}
9981000 iex> NaiveDateTime.from_erl({{2000, 13, 1}, {13, 30, 15}})
@@ -1001,7 +1003,11 @@ defmodule NaiveDateTime do
10011003 {:error, :invalid_date}
10021004
10031005 """
1004- @ spec from_erl ( :calendar . datetime ( ) , Calendar . microsecond ( ) , Calendar . calendar ( ) ) ::
1006+ @ spec from_erl (
1007+ :calendar . datetime ( ) ,
1008+ Calendar . microsecond ( ) | non_neg_integer ( ) ,
1009+ Calendar . calendar ( )
1010+ ) ::
10051011 { :ok , t } | { :error , atom }
10061012 def from_erl ( tuple , microsecond \\ { 0 , 0 } , calendar \\ Calendar.ISO )
10071013
@@ -1020,13 +1026,19 @@ defmodule NaiveDateTime do
10201026
10211027 iex> NaiveDateTime.from_erl!({{2000, 1, 1}, {13, 30, 15}})
10221028 ~N[2000-01-01 13:30:15]
1029+ iex> NaiveDateTime.from_erl!({{2000, 1, 1}, {13, 30, 15}}, 5000)
1030+ ~N[2000-01-01 13:30:15.005000]
10231031 iex> NaiveDateTime.from_erl!({{2000, 1, 1}, {13, 30, 15}}, {5000, 3})
10241032 ~N[2000-01-01 13:30:15.005]
10251033 iex> NaiveDateTime.from_erl!({{2000, 13, 1}, {13, 30, 15}})
10261034 ** (ArgumentError) cannot convert {{2000, 13, 1}, {13, 30, 15}} to naive datetime, reason: :invalid_date
10271035
10281036 """
1029- @ spec from_erl! ( :calendar . datetime ( ) , Calendar . microsecond ( ) , Calendar . calendar ( ) ) :: t
1037+ @ spec from_erl! (
1038+ :calendar . datetime ( ) ,
1039+ Calendar . microsecond ( ) | non_neg_integer ( ) ,
1040+ Calendar . calendar ( )
1041+ ) :: t
10301042 def from_erl! ( tuple , microsecond \\ { 0 , 0 } , calendar \\ Calendar.ISO ) do
10311043 case from_erl ( tuple , microsecond , calendar ) do
10321044 { :ok , value } ->
0 commit comments