AstroHinduLunar (Calendars v0.2.4) View Source

The AstroHinduLunar calendar module.

Link to this section Summary

Functions

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

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

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

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

Compares two AstroHinduLunar dates and returns...

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

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

Returns the day field of a AstroHinduLunar date.

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

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

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

Returns the number of fields in a AstroHinduLunar date

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

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

Converts a fixed day to a AstroHinduLunar date.

Converts a Julian Day into the equivalent AstroHinduLunar date.

Converts a RataDie date into the equivalent AstroHinduLunar date.

Converts a Unix date into the equivalent AstroHinduLunar date.

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

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

Returns the internal keyword of the AstroHinduLunar calendar.

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

Returns the leap_day field of a AstroHinduLunar date.

Returns the leap_month field of a AstroHinduLunar date.

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

Returns the module of the AstroHinduLunar calendar.

Returns the month field of a AstroHinduLunar date.

Returns the internal name of the AstroHinduLunar calendar.

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

Returns the start of the day in the AstroHinduLunar calendar.

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

Converts a AstroHinduLunar date tuple into a fixed day.

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

Converts a AstroHinduLunar date into the equivalent Julian Day.

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

Converts a AstroHinduLunar date into the equivalent RataDie date.

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

Converts a AstroHinduLunar date into the equivalent Unix date.

Converts a AstroHinduLunar 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 AstroHinduLunar date.

Returns the year field of a AstroHinduLunar date.

Link to this section Types

Link to this type

astro_hindu_lunar_date()

View Source

Specs

Link to this type

astro_hindu_lunar_day()

View Source

Specs

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

astro_hindu_lunar_leap_day()

View Source

Specs

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

astro_hindu_lunar_leap_month()

View Source

Specs

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

astro_hindu_lunar_month()

View Source

Specs

astro_hindu_lunar_month() :: 1..12
Link to this type

astro_hindu_lunar_year()

View Source

Specs

astro_hindu_lunar_year() :: integer()

Specs

fixed() :: integer()

Specs

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

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

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

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

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

Specs

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

This is a convenience function to simplify certain function calls.

Examples

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

Specs

as_fixed(fixed() | astro_hindu_lunar_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

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

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

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

Specs

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

Compares two AstroHinduLunar 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.AstroHinduLunar.compare({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  :eq
  iex>Elixir.AstroHinduLunar.compare({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  :lt
  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date from its fields year, month, leap_month, day, leap_day.

Example

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

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

day(cal_date, type \\ :value)

View Source

Specs

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

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

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

Specs

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

Examples

  iex>Elixir.AstroHinduLunar.eq({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  true
  iex>Elixir.AstroHinduLunar.eq({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  false
  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date at field_index.

Examples

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

Specs

field_atoms() :: [atom()]

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

Example

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

Specs

field_count() :: integer()

Returns the number of fields in a AstroHinduLunar date

Example

  iex>Elixir.AstroHinduLunar.field_count()
  5

Specs

field_index(atom()) :: integer()

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

Examples

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

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

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

Specs

from_fixed(fixed()) :: astro_hindu_lunar_date()

Converts a fixed day to a AstroHinduLunar date.

Example

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

Specs

from_jd(tuple() | number()) :: astro_hindu_lunar_date()

Converts a Julian Day into the equivalent AstroHinduLunar date.

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

Examples

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

Specs

from_rata_die(tuple() | integer()) :: astro_hindu_lunar_date()

Converts a RataDie date into the equivalent AstroHinduLunar date.

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

Examples

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

Specs

from_unix(tuple() | integer()) :: astro_hindu_lunar_date()

Converts a Unix date into the equivalent AstroHinduLunar date.

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

Examples

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

Specs

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

Examples

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

Specs

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

Examples

  iex>Elixir.AstroHinduLunar.gt({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  false
  iex>Elixir.AstroHinduLunar.gt({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  false
  iex>Elixir.AstroHinduLunar.gt({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  true

Specs

keyword() :: atom()

Returns the internal keyword of the AstroHinduLunar calendar.

Example

  iex>Elixir.AstroHinduLunar.keyword()
  :astro_hindu_lunar

Specs

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

Examples

  iex>Elixir.AstroHinduLunar.le({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  true
  iex>Elixir.AstroHinduLunar.le({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  true
  iex>Elixir.AstroHinduLunar.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() | astro_hindu_lunar_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the leap_day field of a AstroHinduLunar 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.AstroHinduLunar.leap_day(730739)
  false
  iex>Elixir.AstroHinduLunar.leap_day(730739, :atom)
  :leap_day
  iex>Elixir.AstroHinduLunar.leap_day(730739, :index)
  4
  iex>Elixir.AstroHinduLunar.leap_day(730739, :name)
  "Leap_day"
  iex>Elixir.AstroHinduLunar.leap_day(730739, :value)
  false

  iex>Elixir.AstroHinduLunar.leap_day({2058, 6, false, 23, false})
  false
  iex>Elixir.AstroHinduLunar.leap_day({2058, 6, false, 23, false}, :atom)
  :leap_day
  iex>Elixir.AstroHinduLunar.leap_day({2058, 6, false, 23, false}, :index)
  4
  iex>Elixir.AstroHinduLunar.leap_day({2058, 6, false, 23, false}, :name)
  "Leap_day"
  iex>Elixir.AstroHinduLunar.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() | astro_hindu_lunar_date(), :atom | :index | :name | :value) ::
  :atom | integer() | String.t() | number()

Returns the leap_month field of a AstroHinduLunar 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.AstroHinduLunar.leap_month(730739)
  false
  iex>Elixir.AstroHinduLunar.leap_month(730739, :atom)
  :leap_month
  iex>Elixir.AstroHinduLunar.leap_month(730739, :index)
  2
  iex>Elixir.AstroHinduLunar.leap_month(730739, :name)
  "Leap_month"
  iex>Elixir.AstroHinduLunar.leap_month(730739, :value)
  false

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

Specs

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

Examples

  iex>Elixir.AstroHinduLunar.lt({2058, 6, false, 23, false}, {2058, 6, false, 23, false})
  false
  iex>Elixir.AstroHinduLunar.lt({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  true
  iex>Elixir.AstroHinduLunar.lt({2058, 9, false, 6, false}, {2058, 6, false, 23, false})
  false

Specs

module() :: module()

Returns the module of the AstroHinduLunar calendar.

Example

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

month(cal_date, type \\ :value)

View Source

Specs

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

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

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

Specs

name() :: atom()

Returns the internal name of the AstroHinduLunar calendar.

Example

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

Specs

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

Example

  iex>Elixir.AstroHinduLunar.range({2058, 6, false, 23, false}, {2058, 9, false, 6, false})
  730739..730839

Specs

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

Returns the start of the day in the AstroHinduLunar calendar.

Possible return values are:

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

Example

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

to_date(date, other_calendar)

View Source

Specs

to_date(astro_hindu_lunar_date(), module()) :: tuple()

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

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

Example

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

Specs

to_fixed(astro_hindu_lunar_date()) :: fixed()

Converts a AstroHinduLunar date tuple into a fixed day.

Example

  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date given by year, month, leap_month, day, leap_day into a fixed day.

Example

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

Specs

to_jd(astro_hindu_lunar_date()) :: {number()}

Converts a AstroHinduLunar date into the equivalent Julian Day.

Example

  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Julian Day.

Example

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

Specs

to_rata_die(astro_hindu_lunar_date()) :: {integer()}

Converts a AstroHinduLunar date into the equivalent RataDie date.

Example

  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date given by year, month, leap_month, day, leap_day into the equivalent RataDie date.

Example

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

Specs

to_unix(astro_hindu_lunar_date()) :: {integer()}

Converts a AstroHinduLunar date into the equivalent Unix date.

Example

  iex>Elixir.AstroHinduLunar.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 AstroHinduLunar date given by year, month, leap_month, day, leap_day into the equivalent Unix date.

Example

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

Specs

today(:fixed | :date) :: fixed() | astro_hindu_lunar_date()

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

Examples

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

year(cal_date, type \\ :value)

View Source

Specs

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

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

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