Ecto.DateTime

Ecto.DateTime

An Ecto type that includes a date and a time.

Summary

Functions

cast(dt)

Casts the given value to datetime

cast!(value)

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

compare(t1, t2)

Compare two datetimes

dump(arg1)

Converts an Ecto.DateTime into a {date, time} tuple

from_date(date)

Converts the given Ecto.Date into Ecto.DateTime with the time being 00:00:00

from_date_and_time(date, time)

Converts the given Ecto.Date and Ecto.Time into Ecto.DateTime

from_erl(arg)

Returns an Ecto.DateTime from an Erlang datetime tuple

from_unix!(integer, unit)
load(datetime)

Converts a {date, time} tuple into an Ecto.DateTime

to_date(date_time)

Converts Ecto.DateTime into an Ecto.Date

to_erl(date_time)

Returns an Erlang datetime tuple from an Ecto.DateTime

to_iso8601(date_time)

Converts Ecto.DateTime to its ISO 8601 representation without timezone specification

to_string(date_time)

Converts Ecto.DateTime to its string representation

to_time(date_time)

Converts Ecto.DateTime into an Ecto.Time

type()

The Ecto primitive type

utc(precision \\ :sec)

Returns an Ecto.DateTime in UTC

Functions

cast(dt)

Casts the given value to datetime.

It supports:

  • a binary in the “YYYY-MM-DD HH:MM:SS” format (may be separated by T and/or followed by “Z”, as in 2014-04-17T14:00:00Z)
  • a binary in the “YYYY-MM-DD HH:MM:SS.USEC” format (may be separated by T and/or followed by “Z”, as in 2014-04-17T14:00:00.030Z)
  • a map with "year", "month","day", "hour", "minute" keys with "second" and "microsecond" as optional keys and values are integers or binaries
  • a map with :year, :month,:day, :hour, :minute keys with :second and :microsecond as optional keys and values are integers or binaries
  • a tuple with {{year, month, day}, {hour, min, sec}} as integers or binaries
  • a tuple with {{year, month, day}, {hour, min, sec, usec}} as integers or binaries
  • an Ecto.DateTime struct itself

cast!(value)

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

compare(t1, t2)

Compare two datetimes.

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

dump(arg1)

Converts an Ecto.DateTime into a {date, time} tuple.

from_date(date)

Converts the given Ecto.Date into Ecto.DateTime with the time being 00:00:00.

from_date_and_time(date, time)

Converts the given Ecto.Date and Ecto.Time into Ecto.DateTime.

from_erl(arg)

Returns an Ecto.DateTime from an Erlang datetime tuple.

from_unix!(integer, unit)

load(datetime)

Converts a {date, time} tuple into an Ecto.DateTime.

to_date(date_time)

Converts Ecto.DateTime into an Ecto.Date.

to_erl(date_time)

Returns an Erlang datetime tuple from an Ecto.DateTime.

to_iso8601(date_time)

Converts Ecto.DateTime to its ISO 8601 representation without timezone specification.

to_string(date_time)

Converts Ecto.DateTime to its string representation.

to_time(date_time)

Converts Ecto.DateTime into an Ecto.Time.

type()

The Ecto primitive type.

utc(precision \\ :sec)

Returns an Ecto.DateTime in UTC.

precision can be :sec or :usec.

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部