MayanHaab (Calendars v0.2.4) View Source
The MayanHaab
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 MayanHaab date as a MayanHaab date.
Returns a MayanHaab date from its fields month, day
.
Returns the day
field of a MayanHaab date.
Returns the epoch of the MayanHaab calendar.
Returns the name of the field atom in a MayanHaab date at field_index
.
Returns a list of the field atoms (names) of a MayanHaab date.
Returns the number of fields in a MayanHaab date
Returns the index (= position) of the field_atom
in a MayanHaab date.
Converts the other_date
of the other_calendar
into the equivalent date of the MayanHaab calendar.
Converts a fixed day to a MayanHaab
date.
Converts a Julian Day into the equivalent MayanHaab date.
Converts a RataDie date into the equivalent MayanHaab date.
Converts a Unix date into the equivalent MayanHaab date.
Returns the internal keyword of the MayanHaab calendar.
Returns the module of the MayanHaab calendar.
Returns the month
field of a MayanHaab date.
Returns the internal name of the MayanHaab calendar.
Link to this section Types
Specs
fixed() :: integer()
Specs
mayan_haab_date() :: {mayan_haab_month(), mayan_haab_day()}
Specs
mayan_haab_day() :: 1..19
Specs
mayan_haab_month() :: 1..19
Specs
t() :: mayan_haab_date()
Link to this section Functions
Specs
as_date(fixed() | mayan_haab_date()) :: mayan_haab_date()
Returns a fixed day or MayanHaab date as a MayanHaab date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.MayanHaab.as_date(730739)
{8, 19}
iex>Elixir.MayanHaab.as_date({8, 19})
{8, 19}
Specs
date(mayan_haab_month(), mayan_haab_day()) :: t()
Returns a MayanHaab date from its fields month, day
.
Example
iex>Elixir.MayanHaab.date(8, 19)
{8, 19}
Specs
day(fixed() | mayan_haab_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the day
field of a MayanHaab date.
The type
parameter determines the type of the returned day:
:atom
returns the internal name of day,:index
returns the position of the day field within the date,:name
returns the common name of the day,:value
returns the value of the day (default).
Examples
iex>Elixir.MayanHaab.day(730739)
19
iex>Elixir.MayanHaab.day(730739, :atom)
:day
iex>Elixir.MayanHaab.day(730739, :index)
1
iex>Elixir.MayanHaab.day(730739, :name)
"Day"
iex>Elixir.MayanHaab.day(730739, :value)
19
iex>Elixir.MayanHaab.day({8, 19})
19
iex>Elixir.MayanHaab.day({8, 19}, :atom)
:day
iex>Elixir.MayanHaab.day({8, 19}, :index)
1
iex>Elixir.MayanHaab.day({8, 19}, :name)
"Day"
iex>Elixir.MayanHaab.day({8, 19}, :value)
19
Specs
epoch() :: number()
Returns the epoch of the MayanHaab calendar.
Example
iex>Elixir.MayanHaab.epoch()
-1137490
Specs
Returns the name of the field atom in a MayanHaab date at field_index
.
Examples
iex>Elixir.MayanHaab.field_atom(0)
:month
iex>Elixir.MayanHaab.field_atom(1)
:day
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a MayanHaab date.
Example
iex>Elixir.MayanHaab.field_atoms()
[:month, :day]
Specs
field_count() :: integer()
Returns the number of fields in a MayanHaab date
Example
iex>Elixir.MayanHaab.field_count()
2
Specs
Returns the index (= position) of the field_atom
in a MayanHaab date.
Examples
iex>Elixir.MayanHaab.field_index(:month)
0
iex>Elixir.MayanHaab.field_index(:day)
1
Specs
from_date(tuple(), module()) :: mayan_haab_date()
from_date(tuple(), module()) :: {:error, String.t()}
Converts the other_date
of the other_calendar
into the equivalent date of the MayanHaab calendar.
Example
iex>Elixir.MayanHaab.from_date({2001, 9, 11}, Gregorian)
{8, 19}
Specs
from_fixed(fixed()) :: mayan_haab_date()
Converts a fixed day to a MayanHaab
date.
Example
iex>Elixir.MayanHaab.from_fixed(730739)
{8, 19}
Specs
from_jd(tuple() | number()) :: mayan_haab_date()
Converts a Julian Day into the equivalent MayanHaab date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.MayanHaab.from_jd({2452163.5})
{8, 19}
iex>Elixir.MayanHaab.from_jd(2452163.5)
{8, 19}
Specs
from_rata_die(tuple() | integer()) :: mayan_haab_date()
Converts a RataDie date into the equivalent MayanHaab date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.MayanHaab.from_rata_die({730739})
{8, 19}
iex>Elixir.MayanHaab.from_rata_die(730739)
{8, 19}
Specs
from_unix(tuple() | integer()) :: mayan_haab_date()
Converts a Unix date into the equivalent MayanHaab date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.MayanHaab.from_unix({1000166400})
{8, 19}
iex>Elixir.MayanHaab.from_unix(1000166400)
{8, 19}
Specs
keyword() :: atom()
Returns the internal keyword of the MayanHaab calendar.
Example
iex>Elixir.MayanHaab.keyword()
:mayan_haab
Specs
module() :: module()
Returns the module of the MayanHaab calendar.
Example
iex>Elixir.MayanHaab.module()
MayanHaab
Specs
month(fixed() | mayan_haab_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the month
field of a MayanHaab date.
The type
parameter determines the type of the returned month:
:atom
returns the internal name of month,:index
returns the position of the month field within the date,:name
returns the common name of the month,:value
returns the value of the month (default).
Examples
iex>Elixir.MayanHaab.month(730739)
8
iex>Elixir.MayanHaab.month(730739, :atom)
:month
iex>Elixir.MayanHaab.month(730739, :index)
0
iex>Elixir.MayanHaab.month(730739, :name)
"Month"
iex>Elixir.MayanHaab.month(730739, :value)
8
iex>Elixir.MayanHaab.month({8, 19})
8
iex>Elixir.MayanHaab.month({8, 19}, :atom)
:month
iex>Elixir.MayanHaab.month({8, 19}, :index)
0
iex>Elixir.MayanHaab.month({8, 19}, :name)
"Month"
iex>Elixir.MayanHaab.month({8, 19}, :value)
8
Specs
name() :: atom()
Returns the internal name of the MayanHaab calendar.
Example
iex>Elixir.MayanHaab.name()
"MayanHaab"