momento v0.1.2 Momento.Date

This module holds all the various date/0, ‘date/1’ and date!/1 methods.

Summary

Functions

Get a DateTime struct representng now

Provides a DateTime struct from any recognizeable form of input, such as an ISO string or UNIX timestamp

Shortcut to get a DateTime struct representing now

Shortcut to get a DateTime struct from any recognizeable form of input, such as an ISO string or UNIX timestamp

Functions

date()

Specs

date :: {:ok, DateTime.t}

Get a DateTime struct representng now.

Examples

iex> Momento.date
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 1, hour: 22, microsecond: {732692, 6},
  minute: 56, month: 7, second: 5, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}
date(arg)

Specs

date(any) :: {:ok, DateTime.t}

Provides a DateTime struct from any recognizeable form of input, such as an ISO string or UNIX timestamp.

Examples

iex> Momento.date("2016-04-20T15:05:13.991Z")
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 20, hour: 15, microsecond: {991000, 6},
  minute: 5, month: 4, second: 13, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}

...> Momento.date("2016-04-20")
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 20, hour: 0, microsecond: {0, 6},
  minute: 0, month: 4, second: 0, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}

...> Momento.date(1467413967)
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 1, hour: 22, microsecond: {0, 0},
  minute: 59, month: 7, second: 27, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}
date!()

Specs

date! :: DateTime.t

Shortcut to get a DateTime struct representing now.

Examples

iex> Momento.date!
%DateTime{calendar: Calendar.ISO, day: 1, hour: 21, microsecond: {0, 0},
 minute: 32, month: 7, second: 15, std_offset: 0, time_zone: "Etc/UTC",
 utc_offset: 0, year: 2016, zone_abbr: "UTC"}
date!(arg)

Specs

date!(any) :: DateTime.t

Shortcut to get a DateTime struct from any recognizeable form of input, such as an ISO string or UNIX timestamp.

Examples

iex> Momento.date!("2016-04-20T15:05:13.991Z")
%DateTime{calendar: Calendar.ISO, day: 20, hour: 15, microsecond: {991000, 6},
 minute: 5, month: 4, second: 13, std_offset: 0, time_zone: "Etc/UTC",
 utc_offset: 0, year: 2016, zone_abbr: "UTC"}

...> Momento.date!("2016-04-20")
%DateTime{calendar: Calendar.ISO, day: 20, hour: 0, microsecond: {0, 6},
 minute: 0, month: 4, second: 0, std_offset: 0, time_zone: "Etc/UTC",
 utc_offset: 0, year: 2016, zone_abbr: "UTC"}

...> Momento.date!(1467413967)
%DateTime{calendar: Calendar.ISO, day: 1, hour: 22, microsecond: {0, 0},
 minute: 59, month: 7, second: 27, std_offset: 0, time_zone: "Etc/UTC",
 utc_offset: 0, year: 2016, zone_abbr: "UTC"}