Ecto.DateTimeRange (Ecto DateTimeRange v2.0.1)
View SourceEcto.DateTimeRange provides modules implementing Ecto.Type to allow
usage of Postgres range times encoding timestamp ranges.
Summary
Functions
Create an Ecto.UTCDateTimeRange from two ISO8601 strings.
Functions
Create an Ecto.UTCDateTimeRange from two ISO8601 strings.
Example
iex> import Ecto.DateTimeRange, only: [sigil_t: 2]
...>
iex> ~t(2020-02-02T00:01:00Z..2020-02-02T00:01:01Z)
%Ecto.DateTimeRange.UTCDateTime{start_at: ~U[2020-02-02T00:01:00Z], end_at: ~U[2020-02-02T00:01:01Z]}
...>
iex> ~t(2020-02-02T00:01:00Z..2020-02-02T00:01:01Z)U
%Ecto.DateTimeRange.UTCDateTime{start_at: ~U[2020-02-02T00:01:00Z], end_at: ~U[2020-02-02T00:01:01Z]}
...>
iex> ~t(2020-02-02T00:01:00..2020-02-02T00:01:01)N
%Ecto.DateTimeRange.NaiveDateTime{start_at: ~N[2020-02-02T00:01:00], end_at: ~N[2020-02-02T00:01:01]}
...>
iex> ~t(00:01:00..00:01:01)T
%Ecto.DateTimeRange.Time{start_at: ~T[00:01:00], end_at: ~T[00:01:01]}
...>
iex> ~t(hi there)
** (ArgumentError) Unable to parse DateTime(s) from input