Olympiad (Calendars v0.2.4) View Source
The Olympiad
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 or another cyclical calendar.
Link to this section Summary
Functions
Returns a fixed day or Olympiad date as a Olympiad date.
Returns the cycle
field of a Olympiad date.
Returns a Olympiad date from its fields cycle, year
.
Returns the name of the field atom in a Olympiad date at field_index
.
Returns a list of the field atoms (names) of a Olympiad date.
Returns the number of fields in a Olympiad date
Returns the index (= position) of the field_atom
in a Olympiad date.
Converts the other_date
of the other_calendar
into the equivalent date of the Olympiad calendar.
Converts a fixed day to a Olympiad
date.
Converts a Julian Day into the equivalent Olympiad date.
Converts a Julian year into its Olympiad equivalent.
Converts a RataDie date into the equivalent Olympiad date.
Converts a Unix date into the equivalent Olympiad date.
Returns the internal keyword of the Olympiad calendar.
Returns the module of the Olympiad calendar.
Returns the internal name of the Olympiad calendar.
Converts a Olympiad into the equivalent Julian year.
Returns the year
field of a Olympiad date.
Link to this section Types
Specs
fixed() :: integer()
Specs
olympiad_cycle() :: :integer
Specs
olympiad_date() :: {olympiad_cycle(), olympiad_year()}
Specs
olympiad_year() :: 1..4
Specs
t() :: olympiad_date()
Link to this section Functions
Specs
as_date(fixed() | olympiad_date()) :: olympiad_date()
Returns a fixed day or Olympiad date as a Olympiad date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Olympiad.as_date(730739)
{695, 1}
iex>Elixir.Olympiad.as_date({695, 1})
{695, 1}
Specs
cycle(fixed() | olympiad_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the cycle
field of a Olympiad date.
The type
parameter determines the type of the returned cycle:
:atom
returns the internal name of cycle,:index
returns the position of the cycle field within the date,:name
returns the common name of the cycle,:value
returns the value of the cycle (default).
Examples
iex>Elixir.Olympiad.cycle(730739)
695
iex>Elixir.Olympiad.cycle(730739, :atom)
:cycle
iex>Elixir.Olympiad.cycle(730739, :index)
0
iex>Elixir.Olympiad.cycle(730739, :name)
"Cycle"
iex>Elixir.Olympiad.cycle(730739, :value)
695
iex>Elixir.Olympiad.cycle({695, 1})
695
iex>Elixir.Olympiad.cycle({695, 1}, :atom)
:cycle
iex>Elixir.Olympiad.cycle({695, 1}, :index)
0
iex>Elixir.Olympiad.cycle({695, 1}, :name)
"Cycle"
iex>Elixir.Olympiad.cycle({695, 1}, :value)
695
Specs
date(olympiad_cycle(), olympiad_year()) :: t()
Returns a Olympiad date from its fields cycle, year
.
Example
iex>Elixir.Olympiad.date(695, 1)
{695, 1}
Specs
Returns the name of the field atom in a Olympiad date at field_index
.
Examples
iex>Elixir.Olympiad.field_atom(0)
:cycle
iex>Elixir.Olympiad.field_atom(1)
:year
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a Olympiad date.
Example
iex>Elixir.Olympiad.field_atoms()
[:cycle, :year]
Specs
field_count() :: integer()
Returns the number of fields in a Olympiad date
Example
iex>Elixir.Olympiad.field_count()
2
Specs
Returns the index (= position) of the field_atom
in a Olympiad date.
Examples
iex>Elixir.Olympiad.field_index(:cycle)
0
iex>Elixir.Olympiad.field_index(:year)
1
Specs
from_date(tuple(), module()) :: olympiad_date()
from_date(tuple(), module()) :: {:error, String.t()}
Converts the other_date
of the other_calendar
into the equivalent date of the Olympiad calendar.
Example
iex>Elixir.Olympiad.from_date({2001, 9, 11}, Gregorian)
{695, 1}
Specs
from_fixed(fixed()) :: olympiad_date()
Converts a fixed day to a Olympiad
date.
Example
iex>Elixir.Olympiad.from_fixed(730739)
{695, 1}
Specs
from_jd(tuple() | number()) :: olympiad_date()
Converts a Julian Day into the equivalent Olympiad date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.Olympiad.from_jd({2452163.5})
{695, 1}
iex>Elixir.Olympiad.from_jd(2452163.5)
{695, 1}
Specs
from_julian_year(integer()) :: olympiad_date()
Converts a Julian year into its Olympiad equivalent.
Examples
iex>Elixir.Olympiad.from_julian_year(-776)
{1, 1}
iex>Elixir.Olympiad.from_julian_year(2020)
{699, 4}
Specs
from_rata_die(tuple() | integer()) :: olympiad_date()
Converts a RataDie date into the equivalent Olympiad date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.Olympiad.from_rata_die({730739})
{695, 1}
iex>Elixir.Olympiad.from_rata_die(730739)
{695, 1}
Specs
from_unix(tuple() | integer()) :: olympiad_date()
Converts a Unix date into the equivalent Olympiad date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.Olympiad.from_unix({1000166400})
{695, 1}
iex>Elixir.Olympiad.from_unix(1000166400)
{695, 1}
Specs
keyword() :: atom()
Returns the internal keyword of the Olympiad calendar.
Example
iex>Elixir.Olympiad.keyword()
:olympiad
Specs
module() :: module()
Returns the module of the Olympiad calendar.
Example
iex>Elixir.Olympiad.module()
Olympiad
Specs
name() :: atom()
Returns the internal name of the Olympiad calendar.
Example
iex>Elixir.Olympiad.name()
"Olympiad"
Specs
to_julian_year(olympiad_date()) :: integer()
Converts a Olympiad into the equivalent Julian year.
Examples
iex>Elixir.Olympiad.to_julian_year({1, 1})
-776
iex>Elixir.Olympiad.to_julian_year({2020, 2})
7302
Specs
year(fixed() | olympiad_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the year
field of a Olympiad date.
The type
parameter determines the type of the returned year:
:atom
returns the internal name of year,:index
returns the position of the year field within the date,:name
returns the common name of the year,:value
returns the value of the year (default).
Examples
iex>Elixir.Olympiad.year(730739)
1
iex>Elixir.Olympiad.year(730739, :atom)
:year
iex>Elixir.Olympiad.year(730739, :index)
1
iex>Elixir.Olympiad.year(730739, :name)
"Year"
iex>Elixir.Olympiad.year(730739, :value)
1
iex>Elixir.Olympiad.year({695, 1})
1
iex>Elixir.Olympiad.year({695, 1}, :atom)
:year
iex>Elixir.Olympiad.year({695, 1}, :index)
1
iex>Elixir.Olympiad.year({695, 1}, :name)
"Year"
iex>Elixir.Olympiad.year({695, 1}, :value)
1