Islamic (Calendars v0.2.4) View Source

The Islamic calendar module.

Link to this section Summary

Functions

Adds the number of days to a fixed day or Islamic date.

Adds the number of years to a fixed year or Islamic date.

Returns the weekday al_ahad of the Islamic calendar.

Returns the weekday al_arba_a of the Islamic calendar.

Returns the weekday al_hamis of the Islamic calendar.

Returns the weekday al_ithnayna of the Islamic calendar.

Returns the weekday al_jum_a of the Islamic calendar.

Returns the weekday al_sabt of the Islamic calendar.

Returns a fixed day or Islamic date as a Islamic date.

Returns a fixed day or Islamic date as a fixed day.

Returns a fixed day or Islamic date either as a fixed day or a Islamic date.

Returns the weekday ath_thalatha of the Islamic calendar.

Compares two Islamic dates and returns...

Returns a Islamic date from its fields year, month, day.

Returns the difference (= number of days) between two Islamic dates.

Returns the day field of a Islamic date.

Returns the number of days in the Islamic year.

Returns the month dhi_al_hijja of the Islamic calendar.

Returns the month dhu_al_quada of the Islamic calendar.

Returns the epoch of the Islamic calendar.

Returns true if Islamic date1 is equal Islamic date2, otherwise false.

Returns the name of the field atom in a Islamic date at field_index.

Returns a list of the field atoms (names) of a Islamic date.

Returns the number of fields in a Islamic date

Returns the index (= position) of the field_atom in a Islamic date.

Converts the other_date of the other_calendar into the equivalent date of the Islamic calendar.

Converts a fixed day to a Islamic date.

Converts a Julian Day into the equivalent Islamic date.

Converts a RataDie date into the equivalent Islamic date.

Converts a Unix date into the equivalent Islamic date.

Returns true if Islamic date1 is greater (= later) than or equal Islamic date2, otherwise false.

Returns true if Islamic date1 is greater (= later) than Islamic date2, otherwise false.

Returns a list of the holidays of the Islamic calendar.

Returns the month jumada_i of the Islamic calendar.

Returns the month jumada_ii of the Islamic calendar.

Returns the internal keyword of the Islamic calendar.

Returns true if Islamic date1 is smaller (= earlier) than or equal Islamic date2, otherwise false.

Returns true if the Islamic year is a leap year, otherwise false.

Returns true if Islamic date1 is smaller (= earlier) than Islamic date2, otherwise false.

Returns the fixed date of Mawlid of the Islamic calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns the average length of a Islamic year.

Returns the module of the Islamic calendar.

Returns the month field of a Islamic date.

Returns a list of the months of the Islamic calendar.

Returns the number of months in the Islamic year.

Returns the month muharram of the Islamic calendar.

Returns the internal name of the Islamic calendar.

Returns the month rabi_i of the Islamic calendar.

Returns the month rabi_ii of the Islamic calendar.

Returns the month rajab of the Islamic calendar.

Returns the month ramadan of the Islamic calendar.

Returns the distance between two Islamic dates as a range of fixed days.

Returns the month safar of the Islamic calendar.

Returns the month sha_ban of the Islamic calendar.

Returns the month shawwal of the Islamic calendar.

Returns the first official use of the Islamic calendar.

Returns the start of the day in the Islamic calendar.

Converts a Islamic date into the equivalent date of the other_calendar.

Converts a Islamic date tuple into a fixed day.

Converts a Islamic date given by year, month, day into a fixed day.

Converts a Islamic date into the equivalent Julian Day.

Converts a Islamic date given by year, month, day into the equivalent Julian Day.

Converts a Islamic date into the equivalent RataDie date.

Converts a Islamic date given by year, month, day into the equivalent RataDie date.

Converts a Islamic date into the equivalent Unix date.

Converts a Islamic date given by year, month, day into the equivalent Unix date.

Returns the current date either as a fixed day or a Islamic date.

Returns a list of the weekdays of the Islamic calendar.

Returns the year field of a Islamic date.

Link to this section Types

Specs

fixed() :: integer()

Specs

islamic_date() :: {islamic_year(), islamic_month(), islamic_day()}

Specs

islamic_day() :: 29..30

Specs

islamic_month() :: 1..12

Specs

islamic_year() :: integer()

Specs

t() :: islamic_date()

Link to this section Functions

Link to this function

add_days(cal_date, days, type \\ :fixed)

View Source

Specs

add_days(fixed() | islamic_date(), integer(), :fixed | :date) ::
  fixed() | islamic_date()

Adds the number of days to a fixed day or Islamic 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 Islamic date.

Examples

  iex>Elixir.Islamic.add_days(730739, 100)
  730839
  iex>Elixir.Islamic.add_days(730739, -100)
  730639

  iex>Elixir.Islamic.add_days(730739, 100, :fixed)
  730839
  iex>Elixir.Islamic.add_days(730739, -100, :fixed)
  730639

  iex>Elixir.Islamic.add_days(730739, 100, :date)
  {1422, 10, 4}
  iex>Elixir.Islamic.add_days(730739, -100, :date)
  {1422, 3, 11}

  iex>Elixir.Islamic.add_days({1422, 6, 22}, 100)
  730839
  iex>Elixir.Islamic.add_days({1422, 6, 22}, -100)
  730639

  iex>Elixir.Islamic.add_days({1422, 6, 22}, 100, :fixed)
  730839
  iex>Elixir.Islamic.add_days({1422, 6, 22}, -100, :fixed)
  730639

  iex>Elixir.Islamic.add_days({1422, 6, 22}, 100, :date)
  {1422, 10, 4}
  iex>Elixir.Islamic.add_days({1422, 6, 22}, -100, :date)
  {1422, 3, 11}
Link to this function

add_years(cal_date, years, type \\ :fixed)

View Source

Specs

add_years(fixed() | islamic_date(), integer(), :fixed | :date) ::
  fixed() | islamic_date()

Adds the number of years to a fixed year or Islamic date.

Because of the different lengths of years the result is calculated using the average length of a year; so the result will not always have the same day of the month as the base date.

If years is negative, the years will be subtracted.

The type parameter determines the type of the returned value:

  • :fixed returns a fixed day (default),
  • :date returns a Islamic date.

Examples

  iex>Elixir.Islamic.add_years(730739, 3)
  731802
  iex>Elixir.Islamic.add_years(730739, -3)
  729675

  iex>Elixir.Islamic.add_years(730739, 3, :fixed)
  731802
  iex>Elixir.Islamic.add_years(730739, -3, :fixed)
  729675

  iex>Elixir.Islamic.add_years(730739, 3, :date)
  {1425, 6, 22}
  iex>Elixir.Islamic.add_years(730739, -3, :date)
  {1419, 6, 21}

  iex>Elixir.Islamic.add_years({1422, 6, 22}, 3)
  731802
  iex>Elixir.Islamic.add_years({1422, 6, 22}, -3)
  729675

  iex>Elixir.Islamic.add_years({1422, 6, 22}, 3, :fixed)
  731802
  iex>Elixir.Islamic.add_years({1422, 6, 22}, -3, :fixed)
  729675

  iex>Elixir.Islamic.add_years({1422, 6, 22}, 3, :date)
  {1425, 6, 22}
  iex>Elixir.Islamic.add_years({1422, 6, 22}, -3, :date)
  {1419, 6, 21}
Link to this function

al_ahad(type \\ :integer)

View Source

Specs

al_ahad(:integer | :name) :: integer()

Returns the weekday al_ahad of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_ahad()
  1
  iex>Elixir.Islamic.al_ahad(:integer)
  1
  iex>Elixir.Islamic.al_ahad(:name)
  "al-ahad"
Link to this function

al_arba_a(type \\ :integer)

View Source

Specs

al_arba_a(:integer | :name) :: integer()

Returns the weekday al_arba_a of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_arba_a()
  4
  iex>Elixir.Islamic.al_arba_a(:integer)
  4
  iex>Elixir.Islamic.al_arba_a(:name)
  "al-arba_a"
Link to this function

al_hamis(type \\ :integer)

View Source

Specs

al_hamis(:integer | :name) :: integer()

Returns the weekday al_hamis of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_hamis()
  5
  iex>Elixir.Islamic.al_hamis(:integer)
  5
  iex>Elixir.Islamic.al_hamis(:name)
  "al-hamis"
Link to this function

al_ithnayna(type \\ :integer)

View Source

Specs

al_ithnayna(:integer | :name) :: integer()

Returns the weekday al_ithnayna of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_ithnayna()
  2
  iex>Elixir.Islamic.al_ithnayna(:integer)
  2
  iex>Elixir.Islamic.al_ithnayna(:name)
  "al-ithnayna"
Link to this function

al_jum_a(type \\ :integer)

View Source

Specs

al_jum_a(:integer | :name) :: integer()

Returns the weekday al_jum_a of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_jum_a()
  6
  iex>Elixir.Islamic.al_jum_a(:integer)
  6
  iex>Elixir.Islamic.al_jum_a(:name)
  "al-jum‘a"
Link to this function

al_sabt(type \\ :integer)

View Source

Specs

al_sabt(:integer | :name) :: integer()

Returns the weekday al_sabt of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.al_sabt()
  7
  iex>Elixir.Islamic.al_sabt(:integer)
  7
  iex>Elixir.Islamic.al_sabt(:name)
  "as-sabt"

Specs

as_date(fixed() | islamic_date()) :: islamic_date()

Returns a fixed day or Islamic date as a Islamic date.

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Islamic.as_date(730739)
  {1422, 6, 22}
  iex>Elixir.Islamic.as_date({1422, 6, 22})
  {1422, 6, 22}

Specs

as_fixed(fixed() | islamic_date()) :: fixed()

Returns a fixed day or Islamic date as a fixed day.

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Islamic.as_fixed(730739)
  730739
  iex>Elixir.Islamic.as_fixed({1422, 6, 22})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

as_type(fixed() | islamic_date(), :fixed | :date) :: fixed() | islamic_date()

Returns a fixed day or Islamic date either as a fixed day or a Islamic date.

The type parameter determines the type of the returned value:

  • :fixed returns a fixed day (default),
  • :date returns a Islamic date.

Examples

  iex>Elixir.Islamic.as_type(730739)
  730739
  iex>Elixir.Islamic.as_type(730739, :fixed)
  730739
  iex>Elixir.Islamic.as_type(730739, :date)
  {1422, 6, 22}
  iex>Elixir.Islamic.as_type({1422, 6, 22})
  730739
  iex>Elixir.Islamic.as_type({1422, 6, 22}, :fixed)
  730739
  iex>Elixir.Islamic.as_type({1422, 6, 22}, :date)
  {1422, 6, 22}
Link to this function

ath_thalatha(type \\ :integer)

View Source

Specs

ath_thalatha(:integer | :name) :: integer()

Returns the weekday ath_thalatha of the Islamic calendar.

The type parameter determines the type of the returned weekday:

  • :integer returns the number of the weekday (default),
  • :name returns the name of the weekday.

Examples

  iex>Elixir.Islamic.ath_thalatha()
  3
  iex>Elixir.Islamic.ath_thalatha(:integer)
  3
  iex>Elixir.Islamic.ath_thalatha(:name)
  "ath-thalatha"

Specs

compare(islamic_date(), islamic_date()) :: :lt | :eq | :gt

Compares two Islamic dates and returns...

  • :lt if date1 is smaller (= earlier) than date2,
  • :eq if date1 is equal date2,
  • :gt if date1 is larger (= later) than date2.

Examples

  iex>Elixir.Islamic.compare({1422, 6, 22}, {1422, 6, 22})
  :eq
  iex>Elixir.Islamic.compare({1422, 6, 22}, {1422, 10, 4})
  :lt
  iex>Elixir.Islamic.compare({1422, 10, 4}, {1422, 6, 22})
  :gt

Specs

Returns a Islamic date from its fields year, month, day.

Example

  iex>Elixir.Islamic.date(1422, 6, 22)
  {1422, 6, 22}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

date_diff(fixed() | islamic_date(), fixed() | islamic_date()) :: integer()

Returns the difference (= number of days) between two Islamic dates.

The dates can be given as fixed days or Islamic 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.Islamic.date_diff(730739, 730839)
  100
  iex>Elixir.Islamic.date_diff(730839, 730739)
  -100
  iex>Elixir.Islamic.date_diff({1422, 6, 22}, {1422, 10, 4})
  100
  iex>Elixir.Islamic.date_diff({1422, 10, 4}, {1422, 6, 22})
  -100
  iex>Elixir.Islamic.date_diff(730739, {1422, 10, 4})
  100
  iex>Elixir.Islamic.date_diff({1422, 6, 22}, 730839)
  100
Link to this function

day(cal_date, type \\ :value)

View Source

Specs

day(fixed() | islamic_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the day field of a Islamic 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.Islamic.day(730739)
  22
  iex>Elixir.Islamic.day(730739, :atom)
  :day
  iex>Elixir.Islamic.day(730739, :index)
  2
  iex>Elixir.Islamic.day(730739, :name)
  "Day"
  iex>Elixir.Islamic.day(730739, :value)
  22

  iex>Elixir.Islamic.day({1422, 6, 22})
  22
  iex>Elixir.Islamic.day({1422, 6, 22}, :atom)
  :day
  iex>Elixir.Islamic.day({1422, 6, 22}, :index)
  2
  iex>Elixir.Islamic.day({1422, 6, 22}, :name)
  "Day"
  iex>Elixir.Islamic.day({1422, 6, 22}, :value)
  22

Specs

days_in_year(islamic_year()) :: integer()

Returns the number of days in the Islamic year.

Examples

  iex>Elixir.Islamic.days_in_year(1421)
  354
  iex>Elixir.Islamic.days_in_year(1422)
  354
Link to this function

dhi_al_hijja(type \\ :integer)

View Source

Specs

dhi_al_hijja(:integer | :name) :: integer()

Returns the month dhi_al_hijja of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.dhi_al_hijja()
  12
  iex>Elixir.Islamic.dhi_al_hijja(:integer)
  12
  iex>Elixir.Islamic.dhi_al_hijja(:name)
  "Dhu al-Hijja"
Link to this function

dhu_al_quada(type \\ :integer)

View Source

Specs

dhu_al_quada(:integer | :name) :: integer()

Returns the month dhu_al_quada of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.dhu_al_quada()
  11
  iex>Elixir.Islamic.dhu_al_quada(:integer)
  11
  iex>Elixir.Islamic.dhu_al_quada(:name)
  "Dhu al-Qa'da"

Specs

epoch() :: number()

Returns the epoch of the Islamic calendar.

Example

  iex>Elixir.Islamic.epoch()
  227015

Specs

Returns true if Islamic date1 is equal Islamic date2, otherwise false.

Examples

  iex>Elixir.Islamic.eq({1422, 6, 22}, {1422, 6, 22})
  true
  iex>Elixir.Islamic.eq({1422, 6, 22}, {1422, 10, 4})
  false
  iex>Elixir.Islamic.eq({1422, 10, 4}, {1422, 6, 22})
  false

Specs

field_atom(integer()) :: atom()

Returns the name of the field atom in a Islamic date at field_index.

Examples

  iex>Elixir.Islamic.field_atom(0)
  :year
  iex>Elixir.Islamic.field_atom(1)
  :month
  iex>Elixir.Islamic.field_atom(2)
  :day

Specs

field_atoms() :: [atom()]

Returns a list of the field atoms (names) of a Islamic date.

Example

  iex>Elixir.Islamic.field_atoms()
  [:year, :month, :day]

Specs

field_count() :: integer()

Returns the number of fields in a Islamic date

Example

  iex>Elixir.Islamic.field_count()
  3

Specs

field_index(atom()) :: integer()

Returns the index (= position) of the field_atom in a Islamic date.

Examples

  iex>Elixir.Islamic.field_index(:year)
  0
  iex>Elixir.Islamic.field_index(:month)
  1
  iex>Elixir.Islamic.field_index(:day)
  2
Link to this function

from_date(other_date, other_calendar)

View Source

Specs

from_date(tuple(), module()) :: islamic_date()
from_date(tuple(), module()) :: {:error, String.t()}

Converts the other_date of the other_calendar into the equivalent date of the Islamic calendar.

Example

  iex>Elixir.Islamic.from_date({2001, 9, 11}, Gregorian)
  {1422, 6, 22}

Specs

from_fixed(fixed()) :: islamic_date()

Converts a fixed day to a Islamic date.

Example

  iex>Elixir.Islamic.from_fixed(730739)
  {1422, 6, 22}

Specs

from_jd(tuple() | number()) :: islamic_date()

Converts a Julian Day into the equivalent Islamic date.

The Julian Day can be given as a tuple or by a Julian day.

Examples

  iex>Elixir.Islamic.from_jd({2452163.5})
  {1422, 6, 22}
  iex>Elixir.Islamic.from_jd(2452163.5)
  {1422, 6, 22}

Specs

from_rata_die(tuple() | integer()) :: islamic_date()

Converts a RataDie date into the equivalent Islamic date.

The RataDie date can be given as a tuple or by a RataDie rd.

Examples

  iex>Elixir.Islamic.from_rata_die({730739})
  {1422, 6, 22}
  iex>Elixir.Islamic.from_rata_die(730739)
  {1422, 6, 22}

Specs

from_unix(tuple() | integer()) :: islamic_date()

Converts a Unix date into the equivalent Islamic date.

The Unix date can be given as a tuple or by Unix seconds.

Examples

  iex>Elixir.Islamic.from_unix({1000166400})
  {1422, 6, 22}
  iex>Elixir.Islamic.from_unix(1000166400)
  {1422, 6, 22}

Specs

Returns true if Islamic date1 is greater (= later) than or equal Islamic date2, otherwise false.

Examples

  iex>Elixir.Islamic.ge({1422, 6, 22}, {1422, 6, 22})
  true
  iex>Elixir.Islamic.ge({1422, 6, 22}, {1422, 10, 4})
  false
  iex>Elixir.Islamic.ge({1422, 10, 4}, {1422, 6, 22})
  true

Specs

Returns true if Islamic date1 is greater (= later) than Islamic date2, otherwise false.

Examples

  iex>Elixir.Islamic.gt({1422, 6, 22}, {1422, 6, 22})
  false
  iex>Elixir.Islamic.gt({1422, 6, 22}, {1422, 10, 4})
  false
  iex>Elixir.Islamic.gt({1422, 10, 4}, {1422, 6, 22})
  true

Returns a list of the holidays of the Islamic 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.Islamic.holidays()
  ["Mawlid"]
  iex>Elixir.Islamic.holidays(:atom)
  [:mawlid]
  iex>Elixir.Islamic.holidays(:name)
  ["Mawlid"]
Link to this function

jumada_i(type \\ :integer)

View Source

Specs

jumada_i(:integer | :name) :: integer()

Returns the month jumada_i of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.jumada_i()
  5
  iex>Elixir.Islamic.jumada_i(:integer)
  5
  iex>Elixir.Islamic.jumada_i(:name)
  "Jumada I (Jumada al-Ula"
Link to this function

jumada_ii(type \\ :integer)

View Source

Specs

jumada_ii(:integer | :name) :: integer()

Returns the month jumada_ii of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.jumada_ii()
  6
  iex>Elixir.Islamic.jumada_ii(:integer)
  6
  iex>Elixir.Islamic.jumada_ii(:name)
  "Jumada II (Jumada al-Ahira"

Specs

keyword() :: atom()

Returns the internal keyword of the Islamic calendar.

Example

  iex>Elixir.Islamic.keyword()
  :islamic

Specs

Returns true if Islamic date1 is smaller (= earlier) than or equal Islamic date2, otherwise false.

Examples

  iex>Elixir.Islamic.le({1422, 6, 22}, {1422, 6, 22})
  true
  iex>Elixir.Islamic.le({1422, 6, 22}, {1422, 10, 4})
  true
  iex>Elixir.Islamic.le({1422, 10, 4}, {1422, 6, 22})
  false

Specs

leap_year?(islamic_year()) :: boolean()

Returns true if the Islamic year is a leap year, otherwise false.

Examples

  iex>Elixir.Islamic.leap_year?(1421)
  false
  iex>Elixir.Islamic.leap_year?(1422)
  false
  iex>Elixir.Islamic.leap_year?(1423)
  true
  iex>Elixir.Islamic.leap_year?(1424)
  false

Specs

Returns true if Islamic date1 is smaller (= earlier) than Islamic date2, otherwise false.

Examples

  iex>Elixir.Islamic.lt({1422, 6, 22}, {1422, 6, 22})
  false
  iex>Elixir.Islamic.lt({1422, 6, 22}, {1422, 10, 4})
  true
  iex>Elixir.Islamic.lt({1422, 10, 4}, {1422, 6, 22})
  false

Specs

Returns the fixed date of Mawlid of the Islamic 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 Islamic date.

Example

  iex>Elixir.Islamic.mawlid(2001)
  {2001, 6, 4}

Specs

mean_year() :: number()

Returns the average length of a Islamic year.

Example

  iex>Elixir.Islamic.mean_year()
  354.3666666666667

Specs

module() :: module()

Returns the module of the Islamic calendar.

Example

  iex>Elixir.Islamic.module()
  Islamic
Link to this function

month(cal_date, type \\ :value)

View Source

Specs

month(fixed() | islamic_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the month field of a Islamic 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.Islamic.month(730739)
  6
  iex>Elixir.Islamic.month(730739, :atom)
  :month
  iex>Elixir.Islamic.month(730739, :index)
  1
  iex>Elixir.Islamic.month(730739, :name)
  "Month"
  iex>Elixir.Islamic.month(730739, :value)
  6

  iex>Elixir.Islamic.month({1422, 6, 22})
  6
  iex>Elixir.Islamic.month({1422, 6, 22}, :atom)
  :month
  iex>Elixir.Islamic.month({1422, 6, 22}, :index)
  1
  iex>Elixir.Islamic.month({1422, 6, 22}, :name)
  "Month"
  iex>Elixir.Islamic.month({1422, 6, 22}, :value)
  6

Specs

months(:atom | :integer | :name) :: [integer() | atom() | String.t()]

Returns a list of the months of the Islamic calendar.

The type parameter determines the type of the returned months:

  • :integer returns the numbers of the months,
  • :atom returns the internal names of the months,
  • :name returns the common names of the months (default).

Examples

  iex>Elixir.Islamic.months()
  ["Muharram", "Safar", "Rabi I (Rabi al-Awwal", "Rabi II (Rabi al-Ahir", "Jumada I (Jumada al-Ula", "Jumada II (Jumada al-Ahira", "Rajab", "Sha'ban", "Ramadan", "Shawwal", "Dhu al-Qa'da", "Dhu al-Hijja"]
  iex>Elixir.Islamic.months(:integer)
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  iex>Elixir.Islamic.months(:atom)
  [:muharram, :safar, :rabi_i, :rabi_ii, :jumada_i, :jumada_ii, :rajab, :sha_ban, :ramadan, :shawwal, :dhu_al_quada, :dhi_al_hijja]
  iex>Elixir.Islamic.months(:name)
  ["Muharram", "Safar", "Rabi I (Rabi al-Awwal", "Rabi II (Rabi al-Ahir", "Jumada I (Jumada al-Ula", "Jumada II (Jumada al-Ahira", "Rajab", "Sha'ban", "Ramadan", "Shawwal", "Dhu al-Qa'da", "Dhu al-Hijja"]

Specs

months_in_year(islamic_year()) :: integer()

Returns the number of months in the Islamic year.

Example

  iex>Elixir.Islamic.months_in_year(730739)
  12
Link to this function

muharram(type \\ :integer)

View Source

Specs

muharram(:integer | :name) :: integer()

Returns the month muharram of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.muharram()
  1
  iex>Elixir.Islamic.muharram(:integer)
  1
  iex>Elixir.Islamic.muharram(:name)
  "Muharram"

Specs

name() :: atom()

Returns the internal name of the Islamic calendar.

Example

  iex>Elixir.Islamic.name()
  "Islamic"
Link to this function

rabi_i(type \\ :integer)

View Source

Specs

rabi_i(:integer | :name) :: integer()

Returns the month rabi_i of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.rabi_i()
  3
  iex>Elixir.Islamic.rabi_i(:integer)
  3
  iex>Elixir.Islamic.rabi_i(:name)
  "Rabi I (Rabi al-Awwal"
Link to this function

rabi_ii(type \\ :integer)

View Source

Specs

rabi_ii(:integer | :name) :: integer()

Returns the month rabi_ii of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.rabi_ii()
  4
  iex>Elixir.Islamic.rabi_ii(:integer)
  4
  iex>Elixir.Islamic.rabi_ii(:name)
  "Rabi II (Rabi al-Ahir"

Specs

rajab(:integer | :name) :: integer()

Returns the month rajab of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.rajab()
  7
  iex>Elixir.Islamic.rajab(:integer)
  7
  iex>Elixir.Islamic.rajab(:name)
  "Rajab"
Link to this function

ramadan(type \\ :integer)

View Source

Specs

ramadan(:integer | :name) :: integer()

Returns the month ramadan of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.ramadan()
  9
  iex>Elixir.Islamic.ramadan(:integer)
  9
  iex>Elixir.Islamic.ramadan(:name)
  "Ramadan"

Specs

range(islamic_date(), islamic_date()) :: integer()

Returns the distance between two Islamic dates as a range of fixed days.

Example

  iex>Elixir.Islamic.range({1422, 6, 22}, {1422, 10, 4})
  730739..730839

Specs

safar(:integer | :name) :: integer()

Returns the month safar of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.safar()
  2
  iex>Elixir.Islamic.safar(:integer)
  2
  iex>Elixir.Islamic.safar(:name)
  "Safar"
Link to this function

sha_ban(type \\ :integer)

View Source

Specs

sha_ban(:integer | :name) :: integer()

Returns the month sha_ban of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.sha_ban()
  8
  iex>Elixir.Islamic.sha_ban(:integer)
  8
  iex>Elixir.Islamic.sha_ban(:name)
  "Sha'ban"
Link to this function

shawwal(type \\ :integer)

View Source

Specs

shawwal(:integer | :name) :: integer()

Returns the month shawwal of the Islamic calendar.

The type parameter determines the type of the returned month:

  • :integer returns the number of the month (default),
  • :name returns the name of the month.

Examples

  iex>Elixir.Islamic.shawwal()
  10
  iex>Elixir.Islamic.shawwal(:integer)
  10
  iex>Elixir.Islamic.shawwal(:name)
  "Shawwal"
Link to this function

start_of_calendar(type \\ :fixed)

View Source

Specs

start_of_calendar(:fixed | :date) :: term()

Returns the first official use of the Islamic calendar.

The type parameter determines the type of the returned value:

  • :fixed returns a fixed day (default),
  • :date returns a Islamic date.

Examples

  iex>Elixir.Islamic.start_of_calendar()
  227015
  iex>Elixir.Islamic.start_of_calendar(:fixed)
  227015
  iex>Elixir.Islamic.start_of_calendar(:date)
  {1, 1, 1}

Specs

start_of_day() :: :midnight | :sunset | :sunrise | :noon

Returns the start of the day in the Islamic calendar.

Possible return values are:

  • :midnight,
  • :noon,
  • :sunrise,
  • :sunset,

Example

  iex>Elixir.Islamic.start_of_day()
  :sunset
Link to this function

to_date(date, other_calendar)

View Source

Specs

to_date(islamic_date(), module()) :: tuple()

Converts a Islamic date into the equivalent date of the other_calendar.

For the following example to work the Gregorian calendar must be available.

Example

  iex>Elixir.Islamic.to_date({1422, 6, 22}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(islamic_date()) :: fixed()

Converts a Islamic date tuple into a fixed day.

Example

  iex>Elixir.Islamic.to_fixed({1422, 6, 22})
  730739
Link to this function

to_fixed(year, month, day)

View Source

Specs

to_fixed(islamic_year(), islamic_month(), islamic_day()) :: fixed()

Converts a Islamic date given by year, month, day into a fixed day.

Example

  iex>Elixir.Islamic.to_fixed(1422, 6, 22)
  730739

Specs

to_jd(islamic_date()) :: {number()}

Converts a Islamic date into the equivalent Julian Day.

Example

  iex>Elixir.Islamic.to_jd({1422, 6, 22})
  {2452163.5}

Specs

Converts a Islamic date given by year, month, day into the equivalent Julian Day.

Example

  iex>Elixir.Islamic.to_jd(1422, 6, 22)
  {2452163.5}

Specs

to_rata_die(islamic_date()) :: {integer()}

Converts a Islamic date into the equivalent RataDie date.

Example

  iex>Elixir.Islamic.to_rata_die({1422, 6, 22})
  {730739}
Link to this function

to_rata_die(year, month, day)

View Source

Specs

to_rata_die(islamic_year(), islamic_month(), islamic_day()) :: {integer()}

Converts a Islamic date given by year, month, day into the equivalent RataDie date.

Example

  iex>Elixir.Islamic.to_rata_die(1422, 6, 22)
  {730739}

Specs

to_unix(islamic_date()) :: {integer()}

Converts a Islamic date into the equivalent Unix date.

Example

  iex>Elixir.Islamic.to_unix({1422, 6, 22})
  {1000166400}
Link to this function

to_unix(year, month, day)

View Source

Specs

to_unix(islamic_year(), islamic_month(), islamic_day()) :: {integer()}

Converts a Islamic date given by year, month, day into the equivalent Unix date.

Example

  iex>Elixir.Islamic.to_unix(1422, 6, 22)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | islamic_date()

Returns the current date either as a fixed day or a Islamic 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 Islamic date.

Examples

  Elixir.Islamic.today()
  730739
  Elixir.Islamic.today(:fixed)
  730739
  Elixir.Islamic.today(:date)
  {1422, 6, 22}

Returns a list of the weekdays of the Islamic calendar.

The type parameter determines the type of the returned weekdays:

  • :integer returns the numbers of the weekdays,
  • :atom returns the internal names of the weekdays,
  • :name returns the common names of the weekdays (default).

Examples

  iex>Elixir.Islamic.weekdays()
  ["al-ahad", "al-ithnayna", "ath-thalatha", "al-arba_a", "al-hamis", "al-jum‘a", "as-sabt"]
  iex>Elixir.Islamic.weekdays(:integer)
  [1, 2, 3, 4, 5, 6, 7]
  iex>Elixir.Islamic.weekdays(:atom)
  [:al_ahad, :al_ithnayna, :ath_thalatha, :al_arba_a, :al_hamis, :al_jum_a, :al_sabt]
  iex>Elixir.Islamic.weekdays(:name)
  ["al-ahad", "al-ithnayna", "ath-thalatha", "al-arba_a", "al-hamis", "al-jum‘a", "as-sabt"]
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

year(fixed() | islamic_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the year field of a Islamic 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.Islamic.year(730739)
  1422
  iex>Elixir.Islamic.year(730739, :atom)
  :year
  iex>Elixir.Islamic.year(730739, :index)
  0
  iex>Elixir.Islamic.year(730739, :name)
  "Year"
  iex>Elixir.Islamic.year(730739, :value)
  1422

  iex>Elixir.Islamic.year({1422, 6, 22})
  1422
  iex>Elixir.Islamic.year({1422, 6, 22}, :atom)
  :year
  iex>Elixir.Islamic.year({1422, 6, 22}, :index)
  0
  iex>Elixir.Islamic.year({1422, 6, 22}, :name)
  "Year"
  iex>Elixir.Islamic.year({1422, 6, 22}, :value)
  1422