Tibetan (Calendars v0.2.4) View Source

The Tibetan calendar module.

Link to this section Summary

Functions

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

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

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

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

Returns a list of the Calixir functions of the Tibetan calendar.

Compares two Tibetan dates and returns...

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

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

Returns the day field of a Tibetan date.

Returns the epoch of the Tibetan calendar.

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

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

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

Returns the number of fields in a Tibetan date

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

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

Converts a fixed day to a Tibetan date.

Converts a Julian Day into the equivalent Tibetan date.

Converts a RataDie date into the equivalent Tibetan date.

Converts a Unix date into the equivalent Tibetan date.

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

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

Returns a list of the holidays of the Tibetan calendar.

Returns the internal keyword of the Tibetan calendar.

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

Returns the leap_day field of a Tibetan date.

Returns the leap_month field of a Tibetan date.

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

Returns the module of the Tibetan calendar.

Returns the month field of a Tibetan date.

Returns the internal name of the Tibetan calendar.

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

Returns the start of the day in the Tibetan calendar.

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

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

Converts a Tibetan date tuple into a fixed day.

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

Converts a Tibetan date into the equivalent Julian Day.

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

Converts a Tibetan date into the equivalent RataDie date.

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

Converts a Tibetan date into the equivalent Unix date.

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

Returns the year field of a Tibetan date.

Link to this section Types

Specs

fixed() :: integer()

Specs

t() :: tibetan_date()

Specs

Specs

tibetan_day() :: 1..30

Specs

tibetan_leap_day() :: :boolean

Specs

tibetan_leap_month() :: :boolean

Specs

tibetan_month() :: 1..12

Specs

tibetan_year() :: :integer

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

  iex>Elixir.Tibetan.add_days(730739, 100, :date)
  {2128, 11, false, 6, false}
  iex>Elixir.Tibetan.add_days(730739, -100, :date)
  {2128, 4, false, 12, false}

  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, 100)
  730839
  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, -100)
  730639

  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, 100, :fixed)
  730839
  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, -100, :fixed)
  730639

  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, 100, :date)
  {2128, 11, false, 6, false}
  iex>Elixir.Tibetan.add_days({2128, 7, false, 23, false}, -100, :date)
  {2128, 4, false, 12, false}

Specs

as_date(fixed() | tibetan_date()) :: tibetan_date()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Tibetan.as_date(730739)
  {2128, 7, false, 23, false}
  iex>Elixir.Tibetan.as_date({2128, 7, false, 23, false})
  {2128, 7, false, 23, false}

Specs

as_fixed(fixed() | tibetan_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Tibetan.as_fixed(730739)
  730739
  iex>Elixir.Tibetan.as_fixed({2128, 7, false, 23, false})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Tibetan.as_type(730739)
  730739
  iex>Elixir.Tibetan.as_type(730739, :fixed)
  730739
  iex>Elixir.Tibetan.as_type(730739, :date)
  {2128, 7, false, 23, false}
  iex>Elixir.Tibetan.as_type({2128, 7, false, 23, false})
  730739
  iex>Elixir.Tibetan.as_type({2128, 7, false, 23, false}, :fixed)
  730739
  iex>Elixir.Tibetan.as_type({2128, 7, false, 23, false}, :date)
  {2128, 7, false, 23, false}
Link to this function

calixir_api(type \\ :atom)

View Source

Returns a list of the Calixir functions of the Tibetan calendar.

The type parameter determines the type of the returned Calixir function:

  • :atom returns the internal names of the functions (default),
  • :spec returns the complete specifications of the functions.

Examples

  iex>Elixir.Tibetan.calixir_api()
  [:tibetan_epoch, :tibetan_sun_equation, :tibetan_moon_equation, :fixed_from_tibetan, :tibetan_from_fixed, :tibetan_leap_month?, :tibetan_leap_day?, :tibetan_new_year]
  iex>Elixir.Tibetan.calixir_api(:atom)
  [:tibetan_epoch, :tibetan_sun_equation, :tibetan_moon_equation, :fixed_from_tibetan, :tibetan_from_fixed, :tibetan_leap_month?, :tibetan_leap_day?, :tibetan_new_year]
  iex>Elixir.Tibetan.calixir_api(:fun_specs)
  [[:tibetan_epoch, []], [:tibetan_sun_equation, [:alpha]], [:tibetan_moon_equation, [:alpha]], [:fixed_from_tibetan, [:year, :month, :leap_month, :day, :leap_day]], [:tibetan_from_fixed, [:fixed]], [:tibetan_leap_month?, [:year, :month]], [:tibetan_leap_day?, [:year, :month, :day]], [:tibetan_new_year, [:gregorian_year]]]

Specs

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

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

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

View Source

Specs

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

Example

  iex>Elixir.Tibetan.date(2128, 7, false, 23, false)
  {2128, 7, false, 23, false}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

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

day(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Tibetan.day({2128, 7, false, 23, false})
  23
  iex>Elixir.Tibetan.day({2128, 7, false, 23, false}, :atom)
  :day
  iex>Elixir.Tibetan.day({2128, 7, false, 23, false}, :index)
  3
  iex>Elixir.Tibetan.day({2128, 7, false, 23, false}, :name)
  "Day"
  iex>Elixir.Tibetan.day({2128, 7, false, 23, false}, :value)
  23

Specs

epoch() :: number()

Returns the epoch of the Tibetan calendar.

Example

  iex>Elixir.Tibetan.epoch()
  -46410

Specs

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

Examples

  iex>Elixir.Tibetan.eq({2128, 7, false, 23, false}, {2128, 7, false, 23, false})
  true
  iex>Elixir.Tibetan.eq({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  false
  iex>Elixir.Tibetan.eq({2128, 11, false, 6, false}, {2128, 7, false, 23, false})
  false

Specs

field_atom(integer()) :: atom()

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

Examples

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

Specs

field_atoms() :: [atom()]

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

Example

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

Specs

field_count() :: integer()

Returns the number of fields in a Tibetan date

Example

  iex>Elixir.Tibetan.field_count()
  5

Specs

field_index(atom()) :: integer()

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

Examples

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

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

  iex>Elixir.Tibetan.from_date({2001, 9, 11}, Gregorian)
  {2128, 7, false, 23, false}

Specs

from_fixed(fixed()) :: tibetan_date()

Converts a fixed day to a Tibetan date.

Example

  iex>Elixir.Tibetan.from_fixed(730739)
  {2128, 7, false, 23, false}

Specs

from_jd(tuple() | number()) :: tibetan_date()

Converts a Julian Day into the equivalent Tibetan date.

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

Examples

  iex>Elixir.Tibetan.from_jd({2452163.5})
  {2128, 7, false, 23, false}
  iex>Elixir.Tibetan.from_jd(2452163.5)
  {2128, 7, false, 23, false}

Specs

from_rata_die(tuple() | integer()) :: tibetan_date()

Converts a RataDie date into the equivalent Tibetan date.

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

Examples

  iex>Elixir.Tibetan.from_rata_die({730739})
  {2128, 7, false, 23, false}
  iex>Elixir.Tibetan.from_rata_die(730739)
  {2128, 7, false, 23, false}

Specs

from_unix(tuple() | integer()) :: tibetan_date()

Converts a Unix date into the equivalent Tibetan date.

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

Examples

  iex>Elixir.Tibetan.from_unix({1000166400})
  {2128, 7, false, 23, false}
  iex>Elixir.Tibetan.from_unix(1000166400)
  {2128, 7, false, 23, false}

Specs

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

Examples

  iex>Elixir.Tibetan.ge({2128, 7, false, 23, false}, {2128, 7, false, 23, false})
  true
  iex>Elixir.Tibetan.ge({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  false
  iex>Elixir.Tibetan.ge({2128, 11, false, 6, false}, {2128, 7, false, 23, false})
  true

Specs

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

Examples

  iex>Elixir.Tibetan.gt({2128, 7, false, 23, false}, {2128, 7, false, 23, false})
  false
  iex>Elixir.Tibetan.gt({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  false
  iex>Elixir.Tibetan.gt({2128, 11, false, 6, false}, {2128, 7, false, 23, false})
  true

Returns a list of the holidays of the Tibetan 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.Tibetan.holidays()
  ["Losar"]
  iex>Elixir.Tibetan.holidays(:atom)
  [:tibetan_new_year]
  iex>Elixir.Tibetan.holidays(:name)
  ["Losar"]

Specs

keyword() :: atom()

Returns the internal keyword of the Tibetan calendar.

Example

  iex>Elixir.Tibetan.keyword()
  :tibetan

Specs

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

Examples

  iex>Elixir.Tibetan.le({2128, 7, false, 23, false}, {2128, 7, false, 23, false})
  true
  iex>Elixir.Tibetan.le({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  true
  iex>Elixir.Tibetan.le({2128, 11, false, 6, false}, {2128, 7, false, 23, false})
  false
Link to this function

leap_day(cal_date, type \\ :value)

View Source

Specs

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

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

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

leap_month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Tibetan.leap_month({2128, 7, false, 23, false})
  false
  iex>Elixir.Tibetan.leap_month({2128, 7, false, 23, false}, :atom)
  :leap_month
  iex>Elixir.Tibetan.leap_month({2128, 7, false, 23, false}, :index)
  2
  iex>Elixir.Tibetan.leap_month({2128, 7, false, 23, false}, :name)
  "Leap_month"
  iex>Elixir.Tibetan.leap_month({2128, 7, false, 23, false}, :value)
  false

Specs

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

Examples

  iex>Elixir.Tibetan.lt({2128, 7, false, 23, false}, {2128, 7, false, 23, false})
  false
  iex>Elixir.Tibetan.lt({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  true
  iex>Elixir.Tibetan.lt({2128, 11, false, 6, false}, {2128, 7, false, 23, false})
  false

Specs

module() :: module()

Returns the module of the Tibetan calendar.

Example

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

month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Tibetan.month({2128, 7, false, 23, false})
  7
  iex>Elixir.Tibetan.month({2128, 7, false, 23, false}, :atom)
  :month
  iex>Elixir.Tibetan.month({2128, 7, false, 23, false}, :index)
  1
  iex>Elixir.Tibetan.month({2128, 7, false, 23, false}, :name)
  "Month"
  iex>Elixir.Tibetan.month({2128, 7, false, 23, false}, :value)
  7

Specs

name() :: atom()

Returns the internal name of the Tibetan calendar.

Example

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

Specs

range(tibetan_date(), tibetan_date()) :: integer()

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

Example

  iex>Elixir.Tibetan.range({2128, 7, false, 23, false}, {2128, 11, false, 6, false})
  730739..730839

Specs

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

Returns the start of the day in the Tibetan calendar.

Possible return values are:

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

Example

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

tibetan_new_year(gregorian_year)

View Source

Specs

tibetan_new_year(Gregorian.gregorian_year()) :: fixed() | tibetan_date()

Returns the fixed date of Losar of the Tibetan 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 Tibetan date.

Example

  iex>Elixir.Tibetan.tibetan_new_year(2001)
  {2001, 2, 24}
Link to this function

to_date(date, other_calendar)

View Source

Specs

to_date(tibetan_date(), module()) :: tuple()

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

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

Example

  iex>Elixir.Tibetan.to_date({2128, 7, false, 23, false}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(tibetan_date()) :: fixed()

Converts a Tibetan date tuple into a fixed day.

Example

  iex>Elixir.Tibetan.to_fixed({2128, 7, false, 23, false})
  730739
Link to this function

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

View Source

Specs

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

Example

  iex>Elixir.Tibetan.to_fixed(2128, 7, false, 23, false)
  730739

Specs

to_jd(tibetan_date()) :: {number()}

Converts a Tibetan date into the equivalent Julian Day.

Example

  iex>Elixir.Tibetan.to_jd({2128, 7, false, 23, false})
  {2452163.5}
Link to this function

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

View Source

Specs

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

Example

  iex>Elixir.Tibetan.to_jd(2128, 7, false, 23, false)
  {2452163.5}

Specs

to_rata_die(tibetan_date()) :: {integer()}

Converts a Tibetan date into the equivalent RataDie date.

Example

  iex>Elixir.Tibetan.to_rata_die({2128, 7, false, 23, false})
  {730739}
Link to this function

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

View Source

Specs

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

Example

  iex>Elixir.Tibetan.to_rata_die(2128, 7, false, 23, false)
  {730739}

Specs

to_unix(tibetan_date()) :: {integer()}

Converts a Tibetan date into the equivalent Unix date.

Example

  iex>Elixir.Tibetan.to_unix({2128, 7, false, 23, false})
  {1000166400}
Link to this function

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

View Source

Specs

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

Example

  iex>Elixir.Tibetan.to_unix(2128, 7, false, 23, false)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | tibetan_date()

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

Examples

  Elixir.Tibetan.today()
  730739
  Elixir.Tibetan.today(:fixed)
  730739
  Elixir.Tibetan.today(:date)
  {2128, 7, false, 23, false}
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Tibetan.year({2128, 7, false, 23, false})
  2128
  iex>Elixir.Tibetan.year({2128, 7, false, 23, false}, :atom)
  :year
  iex>Elixir.Tibetan.year({2128, 7, false, 23, false}, :index)
  0
  iex>Elixir.Tibetan.year({2128, 7, false, 23, false}, :name)
  "Year"
  iex>Elixir.Tibetan.year({2128, 7, false, 23, false}, :value)
  2128