timex v2.1.5 Timex.Date
This module represents all functions specific to creating/manipulating/comparing Dates (year/month/day)
Summary
Functions
See docs for Timex.compare/3
See docs for Timex.diff/3
Returns a Date representing the date of the UNIX epoch
Converts from a date/time value to a Date struct representing that date
WARNING: This is here to ease the migration to 2.x, but is deprecated
Given an integer value representing days since the reference date (:epoch or :zero), returns a Date struct representing that date
Like from/1, but more explicit about it’s inputs (Erlang date/datetime tuples only)
Given an integer value representing microseconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Given an integer value representing milliseconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Given an integer value representing seconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Given an Erlang timestamp, converts it to a Date struct representing the date of that timestamp
Returns today’s date as a Date struct. If given a timezone, returns whatever “today” is in that timezone
See docs for Timex.set/2 for details
Shifts the given Date based on the provided options. See Timex.shift/2 for more information
Converts a Date to a DateTime in UTC
Convert the date to an integer number of days since Epoch or year 0
Convert a date to an integer number of seconds since Epoch or year 0
See Timex.Date.to_seconds/1
Convert a date to a timestamp value consumable by the Time module
Returns today’s date as a Date struct. If given a timezone, returns whatever “today” is in that timezone
Returns a Date representing the first day of year zero
Types
t :: %Timex.Date{calendar: term, day: term, month: term, year: term}
Functions
See docs for Timex.compare/3
See docs for Timex.diff/3
Specs
from(Types.valid_datetime | Types.dtz | Types.phoenix_datetime_select_params) ::
Timex.Date.t |
{:error, term}
Converts from a date/time value to a Date struct representing that date
WARNING: This is here to ease the migration to 2.x, but is deprecated.
Converts a value of the provided type to a Date struct, relative to the reference date (:epoch or :zero)
Specs
from_days(non_neg_integer, :epoch | :zero) ::
Timex.Date.t |
{:error, term}
Given an integer value representing days since the reference date (:epoch or :zero), returns a Date struct representing that date
Specs
from_microseconds(non_neg_integer, :epoch | :zero) ::
Timex.Date.t |
{:error, term}
Given an integer value representing microseconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Specs
from_milliseconds(non_neg_integer, :epoch | :zero) ::
Timex.Date.t |
{:error, term}
Given an integer value representing milliseconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Specs
from_seconds(non_neg_integer, :epoch | :zero) ::
Timex.Date.t |
{:error, term}
Given an integer value representing seconds since the reference date (:epoch or :zero), returns a Date struct representing that date
Specs
from_timestamp(Types.timestamp, :epoch | :zero) ::
Timex.Date.t |
{:error, term}
Given an Erlang timestamp, converts it to a Date struct representing the date of that timestamp
Specs
now :: Timex.Date.t | {:error, term}
Returns today’s date as a Date struct. If given a timezone, returns whatever “today” is in that timezone
Specs
set(Timex.Date.t, [{atom, term}]) ::
Timex.Date.t |
{:error, term}
See docs for Timex.set/2 for details.
Specs
shift(Timex.Date.t, [{atom, term}]) ::
Timex.Date.t |
{:error, term}
Shifts the given Date based on the provided options. See Timex.shift/2 for more information.
Specs
to_datetime(Timex.Date.t) ::
Timex.DateTime.t |
{:error, term}
Converts a Date to a DateTime in UTC
Specs
to_days(Timex.Date.t, :epoch | :zero) ::
integer |
{:error, term}
Convert the date to an integer number of days since Epoch or year 0.
See also Timex.diff/3
if you want to specify an arbitray reference date.
Examples
iex> Timex.date({1970, 1, 15}) |> Elixir.Timex.Date.to_days
14
Specs
to_seconds(Timex.Date.t, :epoch | :zero) ::
integer |
{:error, term}
Convert a date to an integer number of seconds since Epoch or year 0.
See also Timex.diff/3
if you want to specify an arbitrary reference date.
Examples
iex> Timex.date({1999, 1, 2}) |> Elixir.Timex.Date.to_seconds
915235200
Specs
to_timestamp(Timex.Date.t, :epoch | :zero) ::
Types.timestamp |
{:error, term}
Convert a date to a timestamp value consumable by the Time module.
See also diff/2
if you want to specify an arbitrary reference date.
Examples
iex> Elixir.Timex.Date.epoch |> Elixir.Timex.Date.to_timestamp {0,0,0}
Specs
today :: Timex.Date.t | {:error, term}
Returns today’s date as a Date struct. If given a timezone, returns whatever “today” is in that timezone