HinduLunar (Calendars v0.2.4) View Source

The HinduLunar calendar module.

Link to this section Summary

Functions

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

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

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

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

Compares two HinduLunar dates and returns...

Returns a HinduLunar date from its fields year, month, leap_month, day, leap_day.

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

Returns the day field of a HinduLunar date.

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

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

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

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

Returns the number of fields in a HinduLunar date

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

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

Converts a fixed day to a HinduLunar date.

Converts a Julian Day into the equivalent HinduLunar date.

Converts a RataDie date into the equivalent HinduLunar date.

Converts a Unix date into the equivalent HinduLunar date.

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

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

Returns the fixed date of Hindu Lunar New Year of the HinduLunar calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns a list of the holidays of the HinduLunar calendar.

Returns the internal keyword of the HinduLunar calendar.

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

Returns the leap_day field of a HinduLunar date.

Returns the leap_month field of a HinduLunar date.

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

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

Returns the module of the HinduLunar calendar.

Returns the month field of a HinduLunar date.

Returns the internal name of the HinduLunar calendar.

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

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

Returns the fixed date of Sacred Wednesday (first) of the HinduLunar calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns the fixed date of Great Night of Shiva of the HinduLunar calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns the start of the day in the HinduLunar calendar.

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

Converts a HinduLunar date tuple into a fixed day.

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into a fixed day.

Converts a HinduLunar date into the equivalent Julian Day.

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Julian Day.

Converts a HinduLunar date into the equivalent RataDie date.

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent RataDie date.

Converts a HinduLunar date into the equivalent Unix date.

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Unix date.

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

Returns the year field of a HinduLunar date.

Link to this section Types

Specs

fixed() :: integer()

Specs

Specs

hindu_lunar_day() :: 1..30
Link to this type

hindu_lunar_leap_day()

View Source

Specs

hindu_lunar_leap_day() :: boolean()
Link to this type

hindu_lunar_leap_month()

View Source

Specs

hindu_lunar_leap_month() :: boolean()

Specs

hindu_lunar_month() :: 1..12

Specs

hindu_lunar_year() :: integer()

Specs

t() :: hindu_lunar_date()

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

  iex>Elixir.HinduLunar.add_days(730739, 100, :date)
  {2058, 9, false, 6, false}
  iex>Elixir.HinduLunar.add_days(730739, -100, :date)
  {2058, 3, false, 12, false}

  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, 100)
  730839
  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, -100)
  730639

  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, 100, :fixed)
  730839
  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, -100, :fixed)
  730639

  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, 100, :date)
  {2058, 9, false, 6, false}
  iex>Elixir.HinduLunar.add_days({2058, 6, false, 23, false}, -100, :date)
  {2058, 3, false, 12, false}

Specs

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.HinduLunar.as_date(730739)
  {2058, 6, false, 23, false}
  iex>Elixir.HinduLunar.as_date({2058, 6, false, 23, false})
  {2058, 6, false, 23, false}

Specs

as_fixed(fixed() | hindu_lunar_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.HinduLunar.as_fixed(730739)
  730739
  iex>Elixir.HinduLunar.as_fixed({2058, 6, false, 23, false})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.HinduLunar.as_type(730739)
  730739
  iex>Elixir.HinduLunar.as_type(730739, :fixed)
  730739
  iex>Elixir.HinduLunar.as_type(730739, :date)
  {2058, 6, false, 23, false}
  iex>Elixir.HinduLunar.as_type({2058, 6, false, 23, false})
  730739
  iex>Elixir.HinduLunar.as_type({2058, 6, false, 23, false}, :fixed)
  730739
  iex>Elixir.HinduLunar.as_type({2058, 6, false, 23, false}, :date)
  {2058, 6, false, 23, false}

Specs

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

Compares two HinduLunar 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.HinduLunar.compare({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  :eq
  iex>Elixir.HinduLunar.compare({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  :lt
  iex>Elixir.HinduLunar.compare({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  :gt
Link to this function

date(year, month, leap_month, day, leap_day)

View Source

Specs

Returns a HinduLunar date from its fields year, month, leap_month, day, leap_day.

Example

  iex>Elixir.HinduLunar.date(2058, 6, false, 23, false)
  {2058, 6, false, 23, false}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

The dates can be given as fixed days or HinduLunar 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.HinduLunar.date_diff(730739, 730839)
  100
  iex>Elixir.HinduLunar.date_diff(730839, 730739)
  -100
  iex>Elixir.HinduLunar.date_diff({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  100
  iex>Elixir.HinduLunar.date_diff({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  -100
  iex>Elixir.HinduLunar.date_diff(730739, {2058, 9, false, 6, false})
  100
  iex>Elixir.HinduLunar.date_diff({2058, 6, false, 23, false}, 730839)
  100
Link to this function

day(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.HinduLunar.day({2058, 6, false, 23, false})
  23
  iex>Elixir.HinduLunar.day({2058, 6, false, 23, false}, :atom)
  :day
  iex>Elixir.HinduLunar.day({2058, 6, false, 23, false}, :index)
  3
  iex>Elixir.HinduLunar.day({2058, 6, false, 23, false}, :name)
  "Day"
  iex>Elixir.HinduLunar.day({2058, 6, false, 23, false}, :value)
  23

Specs

Returns the fixed date of Diwali of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.diwali(2001)
  {2001, 11, 16}

Specs

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

Examples

  iex>Elixir.HinduLunar.eq({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  true
  iex>Elixir.HinduLunar.eq({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  false
  iex>Elixir.HinduLunar.eq({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  false

Specs

field_atom(integer()) :: atom()

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

Examples

  iex>Elixir.HinduLunar.field_atom(0)
  :year
  iex>Elixir.HinduLunar.field_atom(1)
  :month
  iex>Elixir.HinduLunar.field_atom(2)
  :leap_month
  iex>Elixir.HinduLunar.field_atom(3)
  :day
  iex>Elixir.HinduLunar.field_atom(4)
  :leap_day

Specs

field_atoms() :: [atom()]

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

Example

  iex>Elixir.HinduLunar.field_atoms()
  [:year, :month, :leap_month, :day, :leap_day]

Specs

field_count() :: integer()

Returns the number of fields in a HinduLunar date

Example

  iex>Elixir.HinduLunar.field_count()
  5

Specs

field_index(atom()) :: integer()

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

Examples

  iex>Elixir.HinduLunar.field_index(:year)
  0
  iex>Elixir.HinduLunar.field_index(:month)
  1
  iex>Elixir.HinduLunar.field_index(:leap_month)
  2
  iex>Elixir.HinduLunar.field_index(:day)
  3
  iex>Elixir.HinduLunar.field_index(:leap_day)
  4
Link to this function

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

  iex>Elixir.HinduLunar.from_date({2001, 9, 11}, Gregorian)
  {2058, 6, false, 23, false}

Specs

from_fixed(fixed()) :: hindu_lunar_date()

Converts a fixed day to a HinduLunar date.

Example

  iex>Elixir.HinduLunar.from_fixed(730739)
  {2058, 6, false, 23, false}

Specs

from_jd(tuple() | number()) :: hindu_lunar_date()

Converts a Julian Day into the equivalent HinduLunar date.

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

Examples

  iex>Elixir.HinduLunar.from_jd({2452163.5})
  {2058, 6, false, 23, false}
  iex>Elixir.HinduLunar.from_jd(2452163.5)
  {2058, 6, false, 23, false}

Specs

from_rata_die(tuple() | integer()) :: hindu_lunar_date()

Converts a RataDie date into the equivalent HinduLunar date.

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

Examples

  iex>Elixir.HinduLunar.from_rata_die({730739})
  {2058, 6, false, 23, false}
  iex>Elixir.HinduLunar.from_rata_die(730739)
  {2058, 6, false, 23, false}

Specs

from_unix(tuple() | integer()) :: hindu_lunar_date()

Converts a Unix date into the equivalent HinduLunar date.

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

Examples

  iex>Elixir.HinduLunar.from_unix({1000166400})
  {2058, 6, false, 23, false}
  iex>Elixir.HinduLunar.from_unix(1000166400)
  {2058, 6, false, 23, false}

Specs

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

Examples

  iex>Elixir.HinduLunar.ge({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  true
  iex>Elixir.HinduLunar.ge({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  false
  iex>Elixir.HinduLunar.ge({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  true

Specs

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

Examples

  iex>Elixir.HinduLunar.gt({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  false
  iex>Elixir.HinduLunar.gt({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  false
  iex>Elixir.HinduLunar.gt({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  true
Link to this function

hindu_lunar_new_year(gregorian_year)

View Source

Specs

hindu_lunar_new_year(Gregorian.gregorian_year()) :: fixed() | hindu_lunar_date()

Returns the fixed date of Hindu Lunar New Year of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.hindu_lunar_new_year(2001)
  {2001, 3, 25}

Returns a list of the holidays of the HinduLunar 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.HinduLunar.holidays()
  ["Birthday of Rama", "Diwali", "Great Night of Shiva", "Hindu Lunar New Year", "Mesha Samkranti", "Sacred Wednesday (first)"]
  iex>Elixir.HinduLunar.holidays(:atom)
  [:rama, :diwali, :shiva, :hindu_lunar_new_year, :mesha_samkranti, :sacred_wednesdays]
  iex>Elixir.HinduLunar.holidays(:name)
  ["Birthday of Rama", "Diwali", "Great Night of Shiva", "Hindu Lunar New Year", "Mesha Samkranti", "Sacred Wednesday (first)"]

Specs

keyword() :: atom()

Returns the internal keyword of the HinduLunar calendar.

Example

  iex>Elixir.HinduLunar.keyword()
  :hindu_lunar

Specs

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

Examples

  iex>Elixir.HinduLunar.le({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  true
  iex>Elixir.HinduLunar.le({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  true
  iex>Elixir.HinduLunar.le({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  false
Link to this function

leap_day(cal_date, type \\ :value)

View Source

Specs

leap_day(fixed() | hindu_lunar_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the leap_day field of a HinduLunar date.

The type parameter determines the type of the returned leap_day:

  • :atom returns the internal name of leap_day,
  • :index returns the position of the leap_day field within the date,
  • :name returns the common name of the leap_day,
  • :value returns the value of the leap_day (default).

Examples

  iex>Elixir.HinduLunar.leap_day(730739)
  false
  iex>Elixir.HinduLunar.leap_day(730739, :atom)
  :leap_day
  iex>Elixir.HinduLunar.leap_day(730739, :index)
  4
  iex>Elixir.HinduLunar.leap_day(730739, :name)
  "Leap_day"
  iex>Elixir.HinduLunar.leap_day(730739, :value)
  false

  iex>Elixir.HinduLunar.leap_day({2058, 6, false, 23, false})
  false
  iex>Elixir.HinduLunar.leap_day({2058, 6, false, 23, false}, :atom)
  :leap_day
  iex>Elixir.HinduLunar.leap_day({2058, 6, false, 23, false}, :index)
  4
  iex>Elixir.HinduLunar.leap_day({2058, 6, false, 23, false}, :name)
  "Leap_day"
  iex>Elixir.HinduLunar.leap_day({2058, 6, false, 23, false}, :value)
  false
Link to this function

leap_month(cal_date, type \\ :value)

View Source

Specs

leap_month(fixed() | hindu_lunar_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the leap_month field of a HinduLunar date.

The type parameter determines the type of the returned leap_month:

  • :atom returns the internal name of leap_month,
  • :index returns the position of the leap_month field within the date,
  • :name returns the common name of the leap_month,
  • :value returns the value of the leap_month (default).

Examples

  iex>Elixir.HinduLunar.leap_month(730739)
  false
  iex>Elixir.HinduLunar.leap_month(730739, :atom)
  :leap_month
  iex>Elixir.HinduLunar.leap_month(730739, :index)
  2
  iex>Elixir.HinduLunar.leap_month(730739, :name)
  "Leap_month"
  iex>Elixir.HinduLunar.leap_month(730739, :value)
  false

  iex>Elixir.HinduLunar.leap_month({2058, 6, false, 23, false})
  false
  iex>Elixir.HinduLunar.leap_month({2058, 6, false, 23, false}, :atom)
  :leap_month
  iex>Elixir.HinduLunar.leap_month({2058, 6, false, 23, false}, :index)
  2
  iex>Elixir.HinduLunar.leap_month({2058, 6, false, 23, false}, :name)
  "Leap_month"
  iex>Elixir.HinduLunar.leap_month({2058, 6, false, 23, false}, :value)
  false

Specs

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

Examples

  iex>Elixir.HinduLunar.lt({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  false
  iex>Elixir.HinduLunar.lt({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  true
  iex>Elixir.HinduLunar.lt({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  false
Link to this function

mesha_samkranti(gregorian_year)

View Source

Specs

mesha_samkranti(Gregorian.gregorian_year()) :: fixed() | hindu_lunar_date()

Returns the fixed date of Mesha Samkranti of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.mesha_samkranti(2001)
  {2001, 4, 14}

Specs

module() :: module()

Returns the module of the HinduLunar calendar.

Example

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

month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.HinduLunar.month({2058, 6, false, 23, false})
  6
  iex>Elixir.HinduLunar.month({2058, 6, false, 23, false}, :atom)
  :month
  iex>Elixir.HinduLunar.month({2058, 6, false, 23, false}, :index)
  1
  iex>Elixir.HinduLunar.month({2058, 6, false, 23, false}, :name)
  "Month"
  iex>Elixir.HinduLunar.month({2058, 6, false, 23, false}, :value)
  6

Specs

name() :: atom()

Returns the internal name of the HinduLunar calendar.

Example

  iex>Elixir.HinduLunar.name()
  "HinduLunar"

Specs

Returns the fixed date of Birthday of Rama of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.rama(2001)
  {2001, 4, 2}

Specs

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

Example

  iex>Elixir.HinduLunar.range({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  730739..730839
Link to this function

sacred_wednesdays(gregorian_year)

View Source

Specs

sacred_wednesdays(Gregorian.gregorian_year()) :: fixed() | hindu_lunar_date()

Returns the fixed date of Sacred Wednesday (first) of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.sacred_wednesdays(2001)
  {2001, 1, 3}

Specs

Returns the fixed date of Great Night of Shiva of the HinduLunar 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 HinduLunar date.

Example

  iex>Elixir.HinduLunar.shiva(2001)
  {2001, 2, 21}

Specs

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

Returns the start of the day in the HinduLunar calendar.

Possible return values are:

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

Example

  iex>Elixir.HinduLunar.start_of_day()
  :midnight
Link to this function

to_date(date, other_calendar)

View Source

Specs

to_date(hindu_lunar_date(), module()) :: tuple()

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

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

Example

  iex>Elixir.HinduLunar.to_date({2058, 6, false, 23, false}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(hindu_lunar_date()) :: fixed()

Converts a HinduLunar date tuple into a fixed day.

Example

  iex>Elixir.HinduLunar.to_fixed({2058, 6, false, 23, false})
  730739
Link to this function

to_fixed(year, month, leap_month, day, leap_day)

View Source

Specs

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into a fixed day.

Example

  iex>Elixir.HinduLunar.to_fixed(2058, 6, false, 23, false)
  730739

Specs

to_jd(hindu_lunar_date()) :: {number()}

Converts a HinduLunar date into the equivalent Julian Day.

Example

  iex>Elixir.HinduLunar.to_jd({2058, 6, false, 23, false})
  {2452163.5}
Link to this function

to_jd(year, month, leap_month, day, leap_day)

View Source

Specs

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Julian Day.

Example

  iex>Elixir.HinduLunar.to_jd(2058, 6, false, 23, false)
  {2452163.5}

Specs

to_rata_die(hindu_lunar_date()) :: {integer()}

Converts a HinduLunar date into the equivalent RataDie date.

Example

  iex>Elixir.HinduLunar.to_rata_die({2058, 6, false, 23, false})
  {730739}
Link to this function

to_rata_die(year, month, leap_month, day, leap_day)

View Source

Specs

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent RataDie date.

Example

  iex>Elixir.HinduLunar.to_rata_die(2058, 6, false, 23, false)
  {730739}

Specs

to_unix(hindu_lunar_date()) :: {integer()}

Converts a HinduLunar date into the equivalent Unix date.

Example

  iex>Elixir.HinduLunar.to_unix({2058, 6, false, 23, false})
  {1000166400}
Link to this function

to_unix(year, month, leap_month, day, leap_day)

View Source

Specs

Converts a HinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Unix date.

Example

  iex>Elixir.HinduLunar.to_unix(2058, 6, false, 23, false)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | hindu_lunar_date()

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

Examples

  Elixir.HinduLunar.today()
  730739
  Elixir.HinduLunar.today(:fixed)
  730739
  Elixir.HinduLunar.today(:date)
  {2058, 6, false, 23, false}
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.HinduLunar.year({2058, 6, false, 23, false})
  2058
  iex>Elixir.HinduLunar.year({2058, 6, false, 23, false}, :atom)
  :year
  iex>Elixir.HinduLunar.year({2058, 6, false, 23, false}, :index)
  0
  iex>Elixir.HinduLunar.year({2058, 6, false, 23, false}, :name)
  "Year"
  iex>Elixir.HinduLunar.year({2058, 6, false, 23, false}, :value)
  2058