Ecto.Date

Ecto.Date

An Ecto type for dates.

Summary

Functions

cast(d)

Casts the given value to date

cast!(value)

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

compare(t1, t2)

Compare two dates

dump(arg1)

Converts an Ecto.Date into a date triplet

from_erl(arg)

Returns an Ecto.Date from an Erlang date tuple

load(arg1)

Converts a date triplet into an Ecto.Date

to_erl(date)

Returns an Erlang date tuple from an Ecto.Date

to_iso8601(date)

Converts Ecto.Date to ISO8601 representation

to_string(date)

Converts Ecto.Date to a readable string representation

type()

The Ecto primitive type

utc()

Returns an Ecto.Date in UTC

Functions

cast(d)

Casts the given value to date.

It supports:

  • a binary in the “YYYY-MM-DD” format
  • 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" and "day" keys with integer or binaries as values
  • a map with :year, :month and :day keys with integer or binaries as values
  • a tuple with {year, month, day} as integers or binaries
  • an Ecto.Date struct itself

cast!(value)

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

compare(t1, t2)

Compare two dates.

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

dump(arg1)

Converts an Ecto.Date into a date triplet.

from_erl(arg)

Returns an Ecto.Date from an Erlang date tuple.

load(arg1)

Converts a date triplet into an Ecto.Date.

to_erl(date)

Returns an Erlang date tuple from an Ecto.Date.

to_iso8601(date)

Converts Ecto.Date to ISO8601 representation.

to_string(date)

Converts Ecto.Date to a readable string representation.

type()

The Ecto primitive type.

utc()

Returns an Ecto.Date in UTC.

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部