View Source Ecto.UTCTimeRange (Ecto DateTimeRange v0.99.0)

An Ecto.Type wrapping a :tstzrange Postgres column. To the application, it appears as a struct with :start_at and :end_at, with :time values.

Deprecated

This module is deprecated in favor of Ecto.DateTimeRange.Time.

defmodule Core.Thing do
  use Ecto.Schema
  import Ecto.Changeset

  schema "things" do
    field :performed_during, Ecto.UTCTimeRange
  end

  @required_attrs ~w[performed_during]a
  def changeset(data \ %__MODULE__{}, attrs) do
    data
    |> cast(attrs, @required_attrs)
    |> validate_required(@required_attrs)
  end
end

Link to this section Summary

Ecto.Type Callbacks

cast(arg1) deprecated

Converts user-provided data (for example from a form) to the Elixir term.

dump(arg1) deprecated

Converts the Elixir term to the Ecto native type.

Declares than when used in embedded schemas, the type will be dumped before being encoded.

Checks if two terms are equal.

load(arg1) deprecated

Converts the Ecto native type to the Elixir term.

Declares the native type that will be used in the database.

Functions

Returns true or false depending on whether the time is falls within the specified range.

parse(string) deprecated

Create an Ecto.UTCDateTimeRange from two ISO8601 strings.

Link to this section Types

@type t() :: %Ecto.UTCTimeRange{end_at: Time.t(), start_at: Time.t()}

Link to this section Ecto.Type Callbacks

This function is deprecated. Use Ecto.DateTimeRange.Time instead of Ecto.UTCTimeRange.

Converts user-provided data (for example from a form) to the Elixir term.

This function is deprecated. Use Ecto.DateTimeRange.Time instead of Ecto.UTCTimeRange.

Converts the Elixir term to the Ecto native type.

Declares than when used in embedded schemas, the type will be dumped before being encoded.

This function is deprecated. Use Ecto.DateTimeRange.Time instead of Ecto.UTCTimeRange.

Checks if two terms are equal.

This function is deprecated. Use Ecto.DateTimeRange.Time instead of Ecto.UTCTimeRange.

Converts the Ecto native type to the Elixir term.

Declares the native type that will be used in the database.

Link to this section Functions

Link to this function

contains?(utc_time_range, time)

View Source
This function is deprecated. Use Ecto.DateTimeRange.Time.contains?/2.
@spec contains?(t(), Time.t()) :: boolean()

Returns true or false depending on whether the time is falls within the specified range.

example

Example

iex> import Ecto.DateTimeRange
...>
iex> Ecto.UTCTimeRange.contains?(~t[01:00:00..02:00:00]T, ~T[00:00:00])
false
iex> Ecto.UTCTimeRange.contains?(~t[01:00:00..02:00:00]T, ~T[01:00:00])
true
iex> Ecto.UTCTimeRange.contains?(~t[01:00:00..02:00:00]T, ~T[01:59:59])
true
iex> Ecto.UTCTimeRange.contains?(~t[01:00:00..02:00:00]T, ~T[02:00:00])
false
This function is deprecated. Use Ecto.DateTimeRange.Time.parse/1.
@spec parse(binary()) :: {:ok, t()} | {:error, term()}

Create an Ecto.UTCDateTimeRange from two ISO8601 strings.

example

Example

iex> Ecto.UTCTimeRange.parse("00:01:00Z..00:01:01Z")
{:ok, %Ecto.UTCTimeRange{start_at: ~T[00:01:00Z], end_at: ~T[00:01:01Z]}}

iex> Ecto.UTCTimeRange.parse("00:01:00Z..later")
{:error, "Unable to parse Time(s) from input"}