🕒 EmojiClock v2.0.4 EmojiClock

Returns a clock emoji for a given hour.

Summary

Functions

Returns a clock emoji for a given Elixir DateTime struct

Returns a clock emoji for a given Elixir DateTime struct

Returns a clock emoji for a given integer hour between 0 and 12

Returns a clock emoji for a given integer hour between 0 and 12

Returns a clock emoji for a given ISO datetime bitsring

Returns a clock emoji for a given ISO datetime bitsring

Returns a clock emoji for a given Elixir NaiveDateTime struct

Returns a clock emoji for a given Elixir NaiveDateTime struct

Returns a clock emoji for the local hour. Accepts an optional integer offset

Returns a clock emoji for the local hour. Accepts an optional integer offset

Returns a clock emoji for a given Elixir Time struct

Returns a clock emoji for a given Elixir Time struct

Returns a clock emoji for a given UNIX timestamp integer

Returns a clock emoji for a given UNIX timestamp integer

Types

datetime()
datetime() :: %DateTime{calendar: module, day: non_neg_integer, hour: non_neg_integer, microsecond: {non_neg_integer, non_neg_integer}, minute: non_neg_integer, month: non_neg_integer, second: non_neg_integer, std_offset: integer, time_zone: String.t, utc_offset: integer, year: non_neg_integer, zone_abbr: String.t}

Functions

datetime(datetime)
datetime(datetime) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given Elixir DateTime struct.

Examples

iex> datetime = %DateTime{calendar: Calendar.ISO,
...>                      day: 7,
...>                      hour: 15,
...>                      microsecond: {817699, 6},
...>                      minute: 5,
...>                      month: 4,
...>                      second: 43,
...>                      std_offset: 0,
...>                      time_zone: "Etc/UTC",
...>                      utc_offset: 0,
...>                      year: 2017,
...>                      zone_abbr: "UTC"}
iex> EmojiClock.datetime(datetime)
{:ok, "🕒"}

iex> datetime = %DateTime{calendar: Calendar.ISO,
...>                      day: 3,
...>                      hour: 8,
...>                      microsecond: {000000, 6},
...>                      minute: 42,
...>                      month: 1,
...>                      second: 23,
...>                      std_offset: 0,
...>                      time_zone: "Etc/UTC",
...>                      utc_offset: 0,
...>                      year: 1985,
...>                      zone_abbr: "UTC"}
iex> EmojiClock.datetime(datetime)
{:ok, "🕗"}

Invalid input returns an error:

iex> EmojiClock.datetime(49)
{:error, :invalid_argument}

iex> EmojiClock.datetime("clock pls")
{:error, :invalid_argument}
datetime!(datetime)
datetime!(datetime) :: String.t

Returns a clock emoji for a given Elixir DateTime struct.

Examples

iex> datetime = %DateTime{calendar: Calendar.ISO,
...>                      day: 7,
...>                      hour: 15,
...>                      microsecond: {817699, 6},
...>                      minute: 5,
...>                      month: 4,
...>                      second: 43,
...>                      std_offset: 0,
...>                      time_zone: "Etc/UTC",
...>                      utc_offset: 0,
...>                      year: 2017,
...>                      zone_abbr: "UTC"}
iex> EmojiClock.datetime!(datetime)
"🕒"

iex> datetime = %DateTime{calendar: Calendar.ISO,
...>                      day: 3,
...>                      hour: 8,
...>                      microsecond: {000000, 6},
...>                      minute: 42,
...>                      month: 1,
...>                      second: 23,
...>                      std_offset: 0,
...>                      time_zone: "Etc/UTC",
...>                      utc_offset: 0,
...>                      year: 1985,
...>                      zone_abbr: "UTC"}
iex> EmojiClock.datetime!(datetime)
"🕗"
hour(hour)
hour(non_neg_integer) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given integer hour between 0 and 12.

Examples

iex> EmojiClock.hour(6)
{:ok, "🕕"}

iex> EmojiClock.hour(12)
{:ok, "🕛"}

Invalid input returns an error:

iex> EmojiClock.hour("2")
{:error, :invalid_argument}

iex> EmojiClock.hour(16)
{:error, :invalid_argument}
hour!(hour)
hour!(non_neg_integer) :: String.t

Returns a clock emoji for a given integer hour between 0 and 12.

Examples

iex> EmojiClock.hour!(6)
"🕕"

iex> EmojiClock.hour!(12)
"🕛"
iso(datetime)
iso(String.t) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given ISO datetime bitsring.

Examples

iex> EmojiClock.iso!("2017-04-06T20:32:16+00:00")
"🕗"

iex> EmojiClock.iso!("1985-01-23T22:07:54Z")
"🕙"

Invalid input returns an error:

iex> EmojiClock.iso(49)
{:error, :invalid_argument}

iex> EmojiClock.iso(~N[2000-01-01 04:00:07.000000])
{:error, :invalid_argument}
iso!(datetime)
iso!(String.t) :: String.t

Returns a clock emoji for a given ISO datetime bitsring.

Examples

iex> EmojiClock.iso!("2017-04-06T20:32:16+00:00")
"🕗"

iex> EmojiClock.iso!("1985-01-23T22:07:54Z")
"🕙"
naive(datetime)
naive(struct) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given Elixir NaiveDateTime struct.

Examples

iex> EmojiClock.naive(~N[2000-01-01 04:00:07.000000])
{:ok, "🕓"}

iex> EmojiClock.naive(~N[1985-01-23 20:30:42.657002])
{:ok, "🕗"}

Invalid input returns an error:

iex> EmojiClock.naive(49)
{:error, :invalid_argument}

iex> EmojiClock.naive("clock pls")
{:error, :invalid_argument}
naive!(datetime)
naive!(struct) :: String.t

Returns a clock emoji for a given Elixir NaiveDateTime struct.

Examples

iex> EmojiClock.naive!(~N[2000-01-01 04:00:07.000000])
"🕓"

iex> EmojiClock.naive!(~N[1985-01-23 20:30:42.657002])
"🕗"
now(offset \\ 0)
now(integer) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for the local hour. Accepts an optional integer offset.

Examples

iex> # If it's 18:37 you'll get {:ok, "🕕"}
iex> {:ok, clock} = EmojiClock.now
iex> is_bitstring(clock)
true

iex> # If it's 18:37 you'll get {:ok, "🕓"}
iex> {:ok, clock} = EmojiClock.now(-2)
iex> is_bitstring(clock)
true

Invalid input returns an error:

iex> EmojiClock.now("+8")
{:error, :invalid_argument}
now!(offset \\ 0)
now!(integer) :: String.t

Returns a clock emoji for the local hour. Accepts an optional integer offset.

Examples

iex> # If it's 18:37 you'll get "🕕"
iex> clock = EmojiClock.now!
iex> is_bitstring(clock)
true
time(time)
time(struct) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given Elixir Time struct.

Examples

iex> EmojiClock.time(~T[14:32:07.052])
{:ok, "🕑"}

iex> EmojiClock.time(~T[08:21:42])
{:ok, "🕗"}

Invalid input returns an error:

iex> EmojiClock.time(49)
{:error, :invalid_argument}

iex> EmojiClock.time("clock pls")
{:error, :invalid_argument}
time!(time)
time!(struct) :: String.t

Returns a clock emoji for a given Elixir Time struct.

Examples

iex> EmojiClock.time!(~T[14:32:07.052])
"🕑"

iex> EmojiClock.time!(~T[08:21:42])
"🕗"
unix(timestamp)
unix(pos_integer) :: {:ok, String.t} | {:error, atom}

Returns a clock emoji for a given UNIX timestamp integer.

Examples

iex> EmojiClock.unix(475359803)
{:ok, "🕗"}

iex> EmojiClock.unix(1491517308)
{:ok, "🕙"}

Invalid input returns an error:

iex> EmojiClock.unix("4753598030")
{:error, :invalid_argument}

iex> EmojiClock.unix("clock pls")
{:error, :invalid_argument}
unix!(timestamp)
unix!(pos_integer) :: String.t

Returns a clock emoji for a given UNIX timestamp integer.

Examples

iex> EmojiClock.unix!(475359803)
"🕗"

iex> EmojiClock.unix!(1491517308)
"🕙"