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