MayanTzolkin (Calendars v0.2.4) View Source
The MayanTzolkin
calendar module.
This is a cyclical calendar. So it is not possible to convert a 'date' of this calendar into a corresponding date of a monotonic calendar or another cyclical calendar.
Link to this section Summary
Functions
Returns a fixed day or MayanTzolkin date as a MayanTzolkin date.
Returns a MayanTzolkin date from its fields tzolkin_name, tzolkin_number
.
Returns the epoch of the MayanTzolkin calendar.
Returns the name of the field atom in a MayanTzolkin date at field_index
.
Returns a list of the field atoms (names) of a MayanTzolkin date.
Returns the number of fields in a MayanTzolkin date
Returns the index (= position) of the field_atom
in a MayanTzolkin date.
Converts the other_date
of the other_calendar
into the equivalent date of the MayanTzolkin calendar.
Converts a fixed day to a MayanTzolkin
date.
Converts a Julian Day into the equivalent MayanTzolkin date.
Converts a RataDie date into the equivalent MayanTzolkin date.
Converts a Unix date into the equivalent MayanTzolkin date.
Returns the internal keyword of the MayanTzolkin calendar.
Returns the module of the MayanTzolkin calendar.
Returns the internal name of the MayanTzolkin calendar.
Returns the tzolkin_name
field of a MayanTzolkin date.
Returns the tzolkin_number
field of a MayanTzolkin date.
Link to this section Types
Specs
fixed() :: integer()
Specs
mayan_tzolkin_date() :: {mayan_tzolkin_tzolkin_name(), mayan_tzolkin_tzolkin_number()}
Specs
mayan_tzolkin_tzolkin_name() :: 1..20
Specs
mayan_tzolkin_tzolkin_number() :: 1..13
Specs
t() :: mayan_tzolkin_date()
Link to this section Functions
Specs
as_date(fixed() | mayan_tzolkin_date()) :: mayan_tzolkin_date()
Returns a fixed day or MayanTzolkin date as a MayanTzolkin date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.MayanTzolkin.as_date(730739)
{6, 1}
iex>Elixir.MayanTzolkin.as_date({6, 1})
{6, 1}
Specs
date(mayan_tzolkin_tzolkin_name(), mayan_tzolkin_tzolkin_number()) :: t()
Returns a MayanTzolkin date from its fields tzolkin_name, tzolkin_number
.
Example
iex>Elixir.MayanTzolkin.date(6, 1)
{6, 1}
Specs
epoch() :: number()
Returns the epoch of the MayanTzolkin calendar.
Example
iex>Elixir.MayanTzolkin.epoch()
-1137301
Specs
Returns the name of the field atom in a MayanTzolkin date at field_index
.
Examples
iex>Elixir.MayanTzolkin.field_atom(0)
:tzolkin_name
iex>Elixir.MayanTzolkin.field_atom(1)
:tzolkin_number
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a MayanTzolkin date.
Example
iex>Elixir.MayanTzolkin.field_atoms()
[:tzolkin_name, :tzolkin_number]
Specs
field_count() :: integer()
Returns the number of fields in a MayanTzolkin date
Example
iex>Elixir.MayanTzolkin.field_count()
2
Specs
Returns the index (= position) of the field_atom
in a MayanTzolkin date.
Examples
iex>Elixir.MayanTzolkin.field_index(:tzolkin_name)
0
iex>Elixir.MayanTzolkin.field_index(:tzolkin_number)
1
Specs
from_date(tuple(), module()) :: mayan_tzolkin_date()
from_date(tuple(), module()) :: {:error, String.t()}
Converts the other_date
of the other_calendar
into the equivalent date of the MayanTzolkin calendar.
Example
iex>Elixir.MayanTzolkin.from_date({2001, 9, 11}, Gregorian)
{6, 1}
Specs
from_fixed(fixed()) :: mayan_tzolkin_date()
Converts a fixed day to a MayanTzolkin
date.
Example
iex>Elixir.MayanTzolkin.from_fixed(730739)
{6, 1}
Specs
from_jd(tuple() | number()) :: mayan_tzolkin_date()
Converts a Julian Day into the equivalent MayanTzolkin date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.MayanTzolkin.from_jd({2452163.5})
{6, 1}
iex>Elixir.MayanTzolkin.from_jd(2452163.5)
{6, 1}
Specs
from_rata_die(tuple() | integer()) :: mayan_tzolkin_date()
Converts a RataDie date into the equivalent MayanTzolkin date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.MayanTzolkin.from_rata_die({730739})
{6, 1}
iex>Elixir.MayanTzolkin.from_rata_die(730739)
{6, 1}
Specs
from_unix(tuple() | integer()) :: mayan_tzolkin_date()
Converts a Unix date into the equivalent MayanTzolkin date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.MayanTzolkin.from_unix({1000166400})
{6, 1}
iex>Elixir.MayanTzolkin.from_unix(1000166400)
{6, 1}
Specs
keyword() :: atom()
Returns the internal keyword of the MayanTzolkin calendar.
Example
iex>Elixir.MayanTzolkin.keyword()
:mayan_tzolkin
Specs
module() :: module()
Returns the module of the MayanTzolkin calendar.
Example
iex>Elixir.MayanTzolkin.module()
MayanTzolkin
Specs
name() :: atom()
Returns the internal name of the MayanTzolkin calendar.
Example
iex>Elixir.MayanTzolkin.name()
"MayanTzolkin"
Specs
tzolkin_name(fixed() | mayan_tzolkin_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the tzolkin_name
field of a MayanTzolkin date.
The type
parameter determines the type of the returned tzolkin_name:
:atom
returns the internal name of tzolkin_name,:index
returns the position of the tzolkin_name field within the date,:name
returns the common name of the tzolkin_name,:value
returns the value of the tzolkin_name (default).
Examples
iex>Elixir.MayanTzolkin.tzolkin_name(730739)
6
iex>Elixir.MayanTzolkin.tzolkin_name(730739, :atom)
:tzolkin_name
iex>Elixir.MayanTzolkin.tzolkin_name(730739, :index)
0
iex>Elixir.MayanTzolkin.tzolkin_name(730739, :name)
"Tzolkin_name"
iex>Elixir.MayanTzolkin.tzolkin_name(730739, :value)
6
iex>Elixir.MayanTzolkin.tzolkin_name({6, 1})
6
iex>Elixir.MayanTzolkin.tzolkin_name({6, 1}, :atom)
:tzolkin_name
iex>Elixir.MayanTzolkin.tzolkin_name({6, 1}, :index)
0
iex>Elixir.MayanTzolkin.tzolkin_name({6, 1}, :name)
"Tzolkin_name"
iex>Elixir.MayanTzolkin.tzolkin_name({6, 1}, :value)
6
Specs
tzolkin_number(fixed() | mayan_tzolkin_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the tzolkin_number
field of a MayanTzolkin date.
The type
parameter determines the type of the returned tzolkin_number:
:atom
returns the internal name of tzolkin_number,:index
returns the position of the tzolkin_number field within the date,:name
returns the common name of the tzolkin_number,:value
returns the value of the tzolkin_number (default).
Examples
iex>Elixir.MayanTzolkin.tzolkin_number(730739)
1
iex>Elixir.MayanTzolkin.tzolkin_number(730739, :atom)
:tzolkin_number
iex>Elixir.MayanTzolkin.tzolkin_number(730739, :index)
1
iex>Elixir.MayanTzolkin.tzolkin_number(730739, :name)
"Tzolkin_number"
iex>Elixir.MayanTzolkin.tzolkin_number(730739, :value)
1
iex>Elixir.MayanTzolkin.tzolkin_number({6, 1})
1
iex>Elixir.MayanTzolkin.tzolkin_number({6, 1}, :atom)
:tzolkin_number
iex>Elixir.MayanTzolkin.tzolkin_number({6, 1}, :index)
1
iex>Elixir.MayanTzolkin.tzolkin_number({6, 1}, :name)
"Tzolkin_number"
iex>Elixir.MayanTzolkin.tzolkin_number({6, 1}, :value)
1