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