timely v0.3.0 Timely.Year
Provides functions for manipulating year numbers.
Link to this section Summary
Functions
Computes the century of the specified year
Interprets the specified number
as a year. If necessary, it guesses the
century nearest the specified :near
option
Link to this section Functions
Computes the century of the specified year
.
Examples
iex> Timely.Year.century 1900
19
iex> Timely.Year.century 34
0
Link to this function
guess(number, list)
guess(integer(), [{:near, integer()}]) :: {:ok, integer()} | {:error, binary()}
Interprets the specified number
as a year. If necessary, it guesses the
century nearest the specified :near
option.
Examples
iex> Timely.Year.guess 17, near: 2017
{:ok, 2017}
iex> Timely.Year.guess 67, near: 2017
{:ok, 1967}
iex> Timely.Year.guess 66, near: 2017
{:ok, 2066}
iex> Timely.Year.guess 2017, near: 2017
{:ok, 2017}
iex> Timely.Year.guess 2017, near: 17
{:error, ":near value 17 has no century"}