Ecto.Time

Ecto.Time

An Ecto type for time.

Summary

Functions

cast(t)

Casts the given value to time

cast!(value)

Same as cast/1 but raises Ecto.CastError on invalid times

compare(t1, t2)

Compare two times

dump(arg1)

Converts an Ecto.Time into a time tuple (in the form {hour, min, sec, usec})

from_erl(arg)

Returns an Ecto.Time from an Erlang time tuple

load(time)

Converts a time tuple like the one returned by dump/1 into an Ecto.Time

to_erl(time)

Returns an Erlang time tuple from an Ecto.Time

to_iso8601(time)

Converts Ecto.Time to its ISO 8601 representation

to_string(time)

Converts Ecto.Time to a string representation

type()

The Ecto primitive type

utc(precision \\ :sec)

Returns an Ecto.Time in UTC

Functions

cast(t)

Casts the given value to time.

It supports:

  • a binary in the “HH:MM:SS” format (may be followed by “Z”, as in 12:00:00Z)
  • a binary in the “HH:MM:SS.USEC” format (may be followed by “Z”, as in 12:00:00.005Z)
  • a map with "hour", "minute" keys with "second" and "microsecond" as optional keys and values are integers or binaries
  • a map with :hour, :minute keys with :second and :microsecond as optional keys and values are integers or binaries
  • a tuple with {hour, min, sec} as integers or binaries
  • a tuple with {hour, min, sec, usec} as integers or binaries
  • an Ecto.Time struct itself

cast!(value)

Same as cast/1 but raises Ecto.CastError on invalid times.

compare(t1, t2)

Compare two times.

Receives two times and compares the t1 against t2 and returns :lt, :eq or :gt.

dump(arg1)

Converts an Ecto.Time into a time tuple (in the form {hour, min, sec, usec}).

from_erl(arg)

Returns an Ecto.Time from an Erlang time tuple.

load(time)

Converts a time tuple like the one returned by dump/1 into an Ecto.Time.

to_erl(time)

Returns an Erlang time tuple from an Ecto.Time.

to_iso8601(time)

Converts Ecto.Time to its ISO 8601 representation.

to_string(time)

Converts Ecto.Time to a string representation.

type()

The Ecto primitive type.

utc(precision \\ :sec)

Returns an Ecto.Time in UTC.

precision can be :sec or :usec.

© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ecto/Ecto.Time.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部