Armenian (Calendars v0.2.4) View Source
The Armenian
calendar module.
Link to this section Summary
Functions
Adds the number of days
to a fixed day or Armenian date.
Returns a fixed day or Armenian date as a Armenian date.
Returns a fixed day or Armenian date as a fixed day.
Returns a fixed day or Armenian date either as a fixed day or a Armenian date.
Compares two Armenian dates and returns...
Returns a Armenian date from its fields year, month, day
.
Returns the difference (= number of days) between two Armenian dates.
Returns the day
field of a Armenian date.
Returns the epoch of the Armenian calendar.
Returns true if Armenian date1
is equal Armenian date2
, otherwise false.
Returns the name of the field atom in a Armenian date at field_index
.
Returns a list of the field atoms (names) of a Armenian date.
Returns the number of fields in a Armenian date
Returns the index (= position) of the field_atom
in a Armenian date.
Converts the other_date
of the other_calendar
into the equivalent date of the Armenian calendar.
Converts a fixed day to a Armenian
date.
Converts a Julian Day into the equivalent Armenian date.
Converts a RataDie date into the equivalent Armenian date.
Converts a Unix date into the equivalent Armenian date.
Returns true if Armenian date1
is greater (= later) than or equal Armenian date2
, otherwise false.
Returns true if Armenian date1
is greater (= later) than Armenian date2
, otherwise false.
Returns the internal keyword of the Armenian calendar.
Returns true if Armenian date1
is smaller (= earlier) than or equal Armenian date2
, otherwise false.
Returns true if Armenian date1
is smaller (= earlier) than Armenian date2
, otherwise false.
Returns the module of the Armenian calendar.
Returns the month
field of a Armenian date.
Returns the internal name of the Armenian calendar.
Returns the distance between two Armenian dates as a range of fixed days.
Returns the start of the day in the Armenian calendar.
Converts a Armenian date
into the equivalent date
of the other_calendar
.
Converts a Armenian date tuple into a fixed day.
Converts a Armenian date given by year, month, day
into a fixed day.
Converts a Armenian date into the equivalent Julian Day.
Converts a Armenian date given by year, month, day
into the equivalent Julian Day.
Converts a Armenian date into the equivalent RataDie date.
Converts a Armenian date given by year, month, day
into the equivalent RataDie date.
Converts a Armenian date into the equivalent Unix date.
Converts a Armenian date given by year, month, day
into the equivalent Unix date.
Returns the current date either as a fixed day or a Armenian date.
Returns the year
field of a Armenian date.
Link to this section Types
Specs
armenian_date() :: {armenian_year(), armenian_month(), armenian_day()}
Specs
armenian_day() :: 1..10
Specs
armenian_month() :: 1..13
Specs
armenian_year() :: integer()
Specs
fixed() :: integer()
Specs
t() :: armenian_date()
Link to this section Functions
Specs
add_days(fixed() | armenian_date(), integer(), :fixed | :date) :: fixed() | armenian_date()
Adds the number of days
to a fixed day or Armenian date.
If days
is negative, the days will be subtracted.
The type
parameter determines the type of the returned value:
:fixed
returns a fixed day (default),:date
returns a Armenian date.
Examples
iex>Elixir.Armenian.add_days(730739, 100)
730839
iex>Elixir.Armenian.add_days(730739, -100)
730639
iex>Elixir.Armenian.add_days(730739, 100, :fixed)
730839
iex>Elixir.Armenian.add_days(730739, -100, :fixed)
730639
iex>Elixir.Armenian.add_days(730739, 100, :date)
{1451, 5, 27}
iex>Elixir.Armenian.add_days(730739, -100, :date)
{1450, 11, 12}
iex>Elixir.Armenian.add_days({1451, 2, 17}, 100)
730839
iex>Elixir.Armenian.add_days({1451, 2, 17}, -100)
730639
iex>Elixir.Armenian.add_days({1451, 2, 17}, 100, :fixed)
730839
iex>Elixir.Armenian.add_days({1451, 2, 17}, -100, :fixed)
730639
iex>Elixir.Armenian.add_days({1451, 2, 17}, 100, :date)
{1451, 5, 27}
iex>Elixir.Armenian.add_days({1451, 2, 17}, -100, :date)
{1450, 11, 12}
Specs
as_date(fixed() | armenian_date()) :: armenian_date()
Returns a fixed day or Armenian date as a Armenian date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Armenian.as_date(730739)
{1451, 2, 17}
iex>Elixir.Armenian.as_date({1451, 2, 17})
{1451, 2, 17}
Specs
as_fixed(fixed() | armenian_date()) :: fixed()
Returns a fixed day or Armenian date as a fixed day.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Armenian.as_fixed(730739)
730739
iex>Elixir.Armenian.as_fixed({1451, 2, 17})
730739
Specs
as_type(fixed() | armenian_date(), :fixed | :date) :: fixed() | armenian_date()
Returns a fixed day or Armenian date either as a fixed day or a Armenian date.
The type
parameter determines the type of the returned value:
:fixed
returns a fixed day (default),:date
returns a Armenian date.
Examples
iex>Elixir.Armenian.as_type(730739)
730739
iex>Elixir.Armenian.as_type(730739, :fixed)
730739
iex>Elixir.Armenian.as_type(730739, :date)
{1451, 2, 17}
iex>Elixir.Armenian.as_type({1451, 2, 17})
730739
iex>Elixir.Armenian.as_type({1451, 2, 17}, :fixed)
730739
iex>Elixir.Armenian.as_type({1451, 2, 17}, :date)
{1451, 2, 17}
Specs
compare(armenian_date(), armenian_date()) :: :lt | :eq | :gt
Compares two Armenian dates and returns...
:lt
ifdate1
is smaller (= earlier) thandate2
,:eq
ifdate1
is equaldate2
,:gt
ifdate1
is larger (= later) thandate2
.
Examples
iex>Elixir.Armenian.compare({1451, 2, 17}, {1451, 2, 17})
:eq
iex>Elixir.Armenian.compare({1451, 2, 17}, {1451, 5, 27})
:lt
iex>Elixir.Armenian.compare({1451, 5, 27}, {1451, 2, 17})
:gt
Specs
date(armenian_year(), armenian_month(), armenian_day()) :: t()
Returns a Armenian date from its fields year, month, day
.
Example
iex>Elixir.Armenian.date(1451, 2, 17)
{1451, 2, 17}
Specs
date_diff(fixed() | armenian_date(), fixed() | armenian_date()) :: integer()
Returns the difference (= number of days) between two Armenian dates.
The dates can be given as fixed days or Armenian dates in arbitrary
combination. The difference is calculated by date2 - date1
.
If cal_date2
is larger (= later) than cal_date1
the result is positive.
If cal_date2
is smaller (= earlier) than cal_date1
the result is negative.
Examples
iex>Elixir.Armenian.date_diff(730739, 730839)
100
iex>Elixir.Armenian.date_diff(730839, 730739)
-100
iex>Elixir.Armenian.date_diff({1451, 2, 17}, {1451, 5, 27})
100
iex>Elixir.Armenian.date_diff({1451, 5, 27}, {1451, 2, 17})
-100
iex>Elixir.Armenian.date_diff(730739, {1451, 5, 27})
100
iex>Elixir.Armenian.date_diff({1451, 2, 17}, 730839)
100
Specs
day(fixed() | armenian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the day
field of a Armenian 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.Armenian.day(730739)
17
iex>Elixir.Armenian.day(730739, :atom)
:day
iex>Elixir.Armenian.day(730739, :index)
2
iex>Elixir.Armenian.day(730739, :name)
"Day"
iex>Elixir.Armenian.day(730739, :value)
17
iex>Elixir.Armenian.day({1451, 2, 17})
17
iex>Elixir.Armenian.day({1451, 2, 17}, :atom)
:day
iex>Elixir.Armenian.day({1451, 2, 17}, :index)
2
iex>Elixir.Armenian.day({1451, 2, 17}, :name)
"Day"
iex>Elixir.Armenian.day({1451, 2, 17}, :value)
17
Specs
epoch() :: number()
Returns the epoch of the Armenian calendar.
Example
iex>Elixir.Armenian.epoch()
201443
Specs
eq(armenian_date(), armenian_date()) :: boolean()
Returns true if Armenian date1
is equal Armenian date2
, otherwise false.
Examples
iex>Elixir.Armenian.eq({1451, 2, 17}, {1451, 2, 17})
true
iex>Elixir.Armenian.eq({1451, 2, 17}, {1451, 5, 27})
false
iex>Elixir.Armenian.eq({1451, 5, 27}, {1451, 2, 17})
false
Specs
Returns the name of the field atom in a Armenian date at field_index
.
Examples
iex>Elixir.Armenian.field_atom(0)
:year
iex>Elixir.Armenian.field_atom(1)
:month
iex>Elixir.Armenian.field_atom(2)
:day
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a Armenian date.
Example
iex>Elixir.Armenian.field_atoms()
[:year, :month, :day]
Specs
field_count() :: integer()
Returns the number of fields in a Armenian date
Example
iex>Elixir.Armenian.field_count()
3
Specs
Returns the index (= position) of the field_atom
in a Armenian date.
Examples
iex>Elixir.Armenian.field_index(:year)
0
iex>Elixir.Armenian.field_index(:month)
1
iex>Elixir.Armenian.field_index(:day)
2
Specs
from_date(tuple(), module()) :: armenian_date()
from_date(tuple(), module()) :: {:error, String.t()}
Converts the other_date
of the other_calendar
into the equivalent date of the Armenian calendar.
Example
iex>Elixir.Armenian.from_date({2001, 9, 11}, Gregorian)
{1451, 2, 17}
Specs
from_fixed(fixed()) :: armenian_date()
Converts a fixed day to a Armenian
date.
Example
iex>Elixir.Armenian.from_fixed(730739)
{1451, 2, 17}
Specs
from_jd(tuple() | number()) :: armenian_date()
Converts a Julian Day into the equivalent Armenian date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.Armenian.from_jd({2452163.5})
{1451, 2, 17}
iex>Elixir.Armenian.from_jd(2452163.5)
{1451, 2, 17}
Specs
from_rata_die(tuple() | integer()) :: armenian_date()
Converts a RataDie date into the equivalent Armenian date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.Armenian.from_rata_die({730739})
{1451, 2, 17}
iex>Elixir.Armenian.from_rata_die(730739)
{1451, 2, 17}
Specs
from_unix(tuple() | integer()) :: armenian_date()
Converts a Unix date into the equivalent Armenian date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.Armenian.from_unix({1000166400})
{1451, 2, 17}
iex>Elixir.Armenian.from_unix(1000166400)
{1451, 2, 17}
Specs
ge(armenian_date(), armenian_date()) :: boolean()
Returns true if Armenian date1
is greater (= later) than or equal Armenian date2
, otherwise false.
Examples
iex>Elixir.Armenian.ge({1451, 2, 17}, {1451, 2, 17})
true
iex>Elixir.Armenian.ge({1451, 2, 17}, {1451, 5, 27})
false
iex>Elixir.Armenian.ge({1451, 5, 27}, {1451, 2, 17})
true
Specs
gt(armenian_date(), armenian_date()) :: boolean()
Returns true if Armenian date1
is greater (= later) than Armenian date2
, otherwise false.
Examples
iex>Elixir.Armenian.gt({1451, 2, 17}, {1451, 2, 17})
false
iex>Elixir.Armenian.gt({1451, 2, 17}, {1451, 5, 27})
false
iex>Elixir.Armenian.gt({1451, 5, 27}, {1451, 2, 17})
true
Specs
keyword() :: atom()
Returns the internal keyword of the Armenian calendar.
Example
iex>Elixir.Armenian.keyword()
:armenian
Specs
le(armenian_date(), armenian_date()) :: boolean()
Returns true if Armenian date1
is smaller (= earlier) than or equal Armenian date2
, otherwise false.
Examples
iex>Elixir.Armenian.le({1451, 2, 17}, {1451, 2, 17})
true
iex>Elixir.Armenian.le({1451, 2, 17}, {1451, 5, 27})
true
iex>Elixir.Armenian.le({1451, 5, 27}, {1451, 2, 17})
false
Specs
lt(armenian_date(), armenian_date()) :: boolean()
Returns true if Armenian date1
is smaller (= earlier) than Armenian date2
, otherwise false.
Examples
iex>Elixir.Armenian.lt({1451, 2, 17}, {1451, 2, 17})
false
iex>Elixir.Armenian.lt({1451, 2, 17}, {1451, 5, 27})
true
iex>Elixir.Armenian.lt({1451, 5, 27}, {1451, 2, 17})
false
Specs
module() :: module()
Returns the module of the Armenian calendar.
Example
iex>Elixir.Armenian.module()
Armenian
Specs
month(fixed() | armenian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the month
field of a Armenian 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.Armenian.month(730739)
2
iex>Elixir.Armenian.month(730739, :atom)
:month
iex>Elixir.Armenian.month(730739, :index)
1
iex>Elixir.Armenian.month(730739, :name)
"Month"
iex>Elixir.Armenian.month(730739, :value)
2
iex>Elixir.Armenian.month({1451, 2, 17})
2
iex>Elixir.Armenian.month({1451, 2, 17}, :atom)
:month
iex>Elixir.Armenian.month({1451, 2, 17}, :index)
1
iex>Elixir.Armenian.month({1451, 2, 17}, :name)
"Month"
iex>Elixir.Armenian.month({1451, 2, 17}, :value)
2
Specs
name() :: atom()
Returns the internal name of the Armenian calendar.
Example
iex>Elixir.Armenian.name()
"Armenian"
Specs
range(armenian_date(), armenian_date()) :: integer()
Returns the distance between two Armenian dates as a range of fixed days.
Example
iex>Elixir.Armenian.range({1451, 2, 17}, {1451, 5, 27})
730739..730839
Specs
start_of_day() :: :midnight | :sunset | :sunrise | :noon
Returns the start of the day in the Armenian calendar.
Possible return values are:
:midnight
,:noon
,:sunrise
,:sunset
,
Example
iex>Elixir.Armenian.start_of_day()
:midnight
Specs
to_date(armenian_date(), module()) :: tuple()
Converts a Armenian date
into the equivalent date
of the other_calendar
.
For the following example to work the Gregorian calendar must be available.
Example
iex>Elixir.Armenian.to_date({1451, 2, 17}, Gregorian)
{2001, 9, 11}
Specs
to_fixed(armenian_date()) :: fixed()
Converts a Armenian date tuple into a fixed day.
Example
iex>Elixir.Armenian.to_fixed({1451, 2, 17})
730739
Specs
to_fixed(armenian_year(), armenian_month(), armenian_day()) :: fixed()
Converts a Armenian date given by year, month, day
into a fixed day.
Example
iex>Elixir.Armenian.to_fixed(1451, 2, 17)
730739
Specs
to_jd(armenian_date()) :: {number()}
Converts a Armenian date into the equivalent Julian Day.
Example
iex>Elixir.Armenian.to_jd({1451, 2, 17})
{2452163.5}
Specs
to_jd(armenian_year(), armenian_month(), armenian_day()) :: {number()}
Converts a Armenian date given by year, month, day
into the equivalent Julian Day.
Example
iex>Elixir.Armenian.to_jd(1451, 2, 17)
{2452163.5}
Specs
to_rata_die(armenian_date()) :: {integer()}
Converts a Armenian date into the equivalent RataDie date.
Example
iex>Elixir.Armenian.to_rata_die({1451, 2, 17})
{730739}
Specs
to_rata_die(armenian_year(), armenian_month(), armenian_day()) :: {integer()}
Converts a Armenian date given by year, month, day
into the equivalent RataDie date.
Example
iex>Elixir.Armenian.to_rata_die(1451, 2, 17)
{730739}
Specs
to_unix(armenian_date()) :: {integer()}
Converts a Armenian date into the equivalent Unix date.
Example
iex>Elixir.Armenian.to_unix({1451, 2, 17})
{1000166400}
Specs
to_unix(armenian_year(), armenian_month(), armenian_day()) :: {integer()}
Converts a Armenian date given by year, month, day
into the equivalent Unix date.
Example
iex>Elixir.Armenian.to_unix(1451, 2, 17)
{1000166400}
Specs
today(:fixed | :date) :: fixed() | armenian_date()
Returns the current date either as a fixed day or a Armenian date.
(This cannot be doctested, because today
is a moving target.)
The type
parameter determines the type of the returned value:
:fixed
returns a fixed day (default),:date
returns a Armenian date.
Examples
Elixir.Armenian.today()
730739
Elixir.Armenian.today(:fixed)
730739
Elixir.Armenian.today(:date)
{1451, 2, 17}
Specs
year(fixed() | armenian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the year
field of a Armenian 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.Armenian.year(730739)
1451
iex>Elixir.Armenian.year(730739, :atom)
:year
iex>Elixir.Armenian.year(730739, :index)
0
iex>Elixir.Armenian.year(730739, :name)
"Year"
iex>Elixir.Armenian.year(730739, :value)
1451
iex>Elixir.Armenian.year({1451, 2, 17})
1451
iex>Elixir.Armenian.year({1451, 2, 17}, :atom)
:year
iex>Elixir.Armenian.year({1451, 2, 17}, :index)
0
iex>Elixir.Armenian.year({1451, 2, 17}, :name)
"Year"
iex>Elixir.Armenian.year({1451, 2, 17}, :value)
1451