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