momento v0.1.1 Momento.Date

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

Summary

Functions

Get a DateTime struct representng now

Get a DateTime struct from a UNIX timestamp. You can provide seconds, milliseconds, microseconds and nanoseconds

Get a DateTime struct from a UNIX timestamp without the tuple. You can provide seconds, milliseconds, microseconds and nanoseconds

Functions

date()

Specs

date :: DateTime.t

Get a DateTime struct representng now.

Examples

iex> Momento.date
%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(DateTime.t) :: DateTime.t
date(String.t) :: DateTime.t
date(integer) :: {:ok, DateTime.t}
date(integer) :: DateTime.t

Get a DateTime struct from a UNIX timestamp. You can provide seconds, milliseconds, microseconds and nanoseconds.

Examples

iex> 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"}}

...> Momento.date(1467414084898)
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 1, hour: 23, microsecond: {898000, 3},
  minute: 1, month: 7, second: 24, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}

...> Momento.date(1467414112393174)
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 1, hour: 23, microsecond: {393174, 6},
  minute: 1, month: 7, second: 52, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}

...> Momento.date(1467414144089210599)
{:ok,
 %DateTime{calendar: Calendar.ISO, day: 1, hour: 23, microsecond: {89210, 6},
  minute: 2, month: 7, second: 24, std_offset: 0, time_zone: "Etc/UTC",
  utc_offset: 0, year: 2016, zone_abbr: "UTC"}}
date!(s)

Get a DateTime struct from a UNIX timestamp without the tuple. You can provide seconds, milliseconds, microseconds and nanoseconds.

Examples

iex> 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"}