NaiveDateTime.new-exclamation-mark

You're seeing just the function new-exclamation-mark, go back to NaiveDateTime module for more information.
Link to this function

new!(date, time)

View Source (since 1.11.0)

Specs

new!(Date.t(), Time.t()) :: t()

Builds a naive datetime from date and time structs.

Examples

iex> NaiveDateTime.new!(~D[2010-01-13], ~T[23:00:07.005])
~N[2010-01-13 23:00:07.005]
Link to this function

new!(year, month, day, hour, minute, second, microsecond \\ {0, 0}, calendar \\ Calendar.ISO)

View Source (since 1.11.0)

Specs

Builds a new ISO naive datetime.

Expects all values to be integers. Returns naive_datetime if each entry fits its appropriate range, raises if time or date is invalid.

Examples

iex> NaiveDateTime.new!(2000, 1, 1, 0, 0, 0)
~N[2000-01-01 00:00:00]
iex> NaiveDateTime.new!(2000, 2, 29, 0, 0, 0)
~N[2000-02-29 00:00:00]
iex> NaiveDateTime.new!(2000, 1, 1, 23, 59, 59, {0, 1})
~N[2000-01-01 23:59:59.0]
iex> NaiveDateTime.new!(2000, 1, 1, 23, 59, 59, 999_999)
~N[2000-01-01 23:59:59.999999]
iex> NaiveDateTime.new!(2000, 1, 1, 23, 59, 59, {0, 1}, Calendar.ISO)
~N[2000-01-01 23:59:59.0]
iex> NaiveDateTime.new!(2000, 1, 1, 24, 59, 59, 999_999)
** (ArgumentError) cannot build naive datetime, reason: :invalid_time