Egyptian (Calendars v0.2.4) View Source

The Egyptian calendar module.

Link to this section Summary

Functions

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

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

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

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

Compares two Egyptian dates and returns...

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

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

Returns the day field of a Egyptian date.

Returns the epoch of the Egyptian calendar.

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

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

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

Returns the number of fields in a Egyptian date

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

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

Converts a fixed day to a Egyptian date.

Converts a Julian Day into the equivalent Egyptian date.

Converts a RataDie date into the equivalent Egyptian date.

Converts a Unix date into the equivalent Egyptian date.

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

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

Returns the internal keyword of the Egyptian calendar.

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

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

Returns the module of the Egyptian calendar.

Returns the month field of a Egyptian date.

Returns the internal name of the Egyptian calendar.

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

Returns the start of the day in the Egyptian calendar.

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

Converts a Egyptian date tuple into a fixed day.

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

Converts a Egyptian date into the equivalent Julian Day.

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

Converts a Egyptian date into the equivalent RataDie date.

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

Converts a Egyptian date into the equivalent Unix date.

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

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

Returns the year field of a Egyptian date.

Link to this section Types

Specs

egyptian_date() :: {egyptian_year(), egyptian_month(), egyptian_day()}

Specs

egyptian_day() :: 1..10

Specs

egyptian_month() :: 1..13

Specs

egyptian_year() :: integer()

Specs

fixed() :: integer()

Specs

t() :: egyptian_date()

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

  iex>Elixir.Egyptian.add_days(730739, 100, :date)
  {2750, 9, 2}
  iex>Elixir.Egyptian.add_days(730739, -100, :date)
  {2750, 2, 12}

  iex>Elixir.Egyptian.add_days({2750, 5, 22}, 100)
  730839
  iex>Elixir.Egyptian.add_days({2750, 5, 22}, -100)
  730639

  iex>Elixir.Egyptian.add_days({2750, 5, 22}, 100, :fixed)
  730839
  iex>Elixir.Egyptian.add_days({2750, 5, 22}, -100, :fixed)
  730639

  iex>Elixir.Egyptian.add_days({2750, 5, 22}, 100, :date)
  {2750, 9, 2}
  iex>Elixir.Egyptian.add_days({2750, 5, 22}, -100, :date)
  {2750, 2, 12}

Specs

as_date(fixed() | egyptian_date()) :: egyptian_date()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Egyptian.as_date(730739)
  {2750, 5, 22}
  iex>Elixir.Egyptian.as_date({2750, 5, 22})
  {2750, 5, 22}

Specs

as_fixed(fixed() | egyptian_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Egyptian.as_fixed(730739)
  730739
  iex>Elixir.Egyptian.as_fixed({2750, 5, 22})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Egyptian.as_type(730739)
  730739
  iex>Elixir.Egyptian.as_type(730739, :fixed)
  730739
  iex>Elixir.Egyptian.as_type(730739, :date)
  {2750, 5, 22}
  iex>Elixir.Egyptian.as_type({2750, 5, 22})
  730739
  iex>Elixir.Egyptian.as_type({2750, 5, 22}, :fixed)
  730739
  iex>Elixir.Egyptian.as_type({2750, 5, 22}, :date)
  {2750, 5, 22}

Specs

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

Compares two Egyptian 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.Egyptian.compare({2750, 5, 22}, {2750, 5, 22})
  :eq
  iex>Elixir.Egyptian.compare({2750, 5, 22}, {2750, 9, 2})
  :lt
  iex>Elixir.Egyptian.compare({2750, 9, 2}, {2750, 5, 22})
  :gt

Specs

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

Example

  iex>Elixir.Egyptian.date(2750, 5, 22)
  {2750, 5, 22}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

The dates can be given as fixed days or Egyptian 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.Egyptian.date_diff(730739, 730839)
  100
  iex>Elixir.Egyptian.date_diff(730839, 730739)
  -100
  iex>Elixir.Egyptian.date_diff({2750, 5, 22}, {2750, 9, 2})
  100
  iex>Elixir.Egyptian.date_diff({2750, 9, 2}, {2750, 5, 22})
  -100
  iex>Elixir.Egyptian.date_diff(730739, {2750, 9, 2})
  100
  iex>Elixir.Egyptian.date_diff({2750, 5, 22}, 730839)
  100
Link to this function

day(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Egyptian.day({2750, 5, 22})
  22
  iex>Elixir.Egyptian.day({2750, 5, 22}, :atom)
  :day
  iex>Elixir.Egyptian.day({2750, 5, 22}, :index)
  2
  iex>Elixir.Egyptian.day({2750, 5, 22}, :name)
  "Day"
  iex>Elixir.Egyptian.day({2750, 5, 22}, :value)
  22

Specs

epoch() :: number()

Returns the epoch of the Egyptian calendar.

Example

  iex>Elixir.Egyptian.epoch()
  -272787

Specs

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

Examples

  iex>Elixir.Egyptian.eq({2750, 5, 22}, {2750, 5, 22})
  true
  iex>Elixir.Egyptian.eq({2750, 5, 22}, {2750, 9, 2})
  false
  iex>Elixir.Egyptian.eq({2750, 9, 2}, {2750, 5, 22})
  false

Specs

field_atom(integer()) :: atom()

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

Examples

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

Specs

field_atoms() :: [atom()]

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

Example

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

Specs

field_count() :: integer()

Returns the number of fields in a Egyptian date

Example

  iex>Elixir.Egyptian.field_count()
  3

Specs

field_index(atom()) :: integer()

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

Examples

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

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

  iex>Elixir.Egyptian.from_date({2001, 9, 11}, Gregorian)
  {2750, 5, 22}

Specs

from_fixed(fixed()) :: egyptian_date()

Converts a fixed day to a Egyptian date.

Example

  iex>Elixir.Egyptian.from_fixed(730739)
  {2750, 5, 22}

Specs

from_jd(tuple() | number()) :: egyptian_date()

Converts a Julian Day into the equivalent Egyptian date.

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

Examples

  iex>Elixir.Egyptian.from_jd({2452163.5})
  {2750, 5, 22}
  iex>Elixir.Egyptian.from_jd(2452163.5)
  {2750, 5, 22}

Specs

from_rata_die(tuple() | integer()) :: egyptian_date()

Converts a RataDie date into the equivalent Egyptian date.

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

Examples

  iex>Elixir.Egyptian.from_rata_die({730739})
  {2750, 5, 22}
  iex>Elixir.Egyptian.from_rata_die(730739)
  {2750, 5, 22}

Specs

from_unix(tuple() | integer()) :: egyptian_date()

Converts a Unix date into the equivalent Egyptian date.

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

Examples

  iex>Elixir.Egyptian.from_unix({1000166400})
  {2750, 5, 22}
  iex>Elixir.Egyptian.from_unix(1000166400)
  {2750, 5, 22}

Specs

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

Examples

  iex>Elixir.Egyptian.ge({2750, 5, 22}, {2750, 5, 22})
  true
  iex>Elixir.Egyptian.ge({2750, 5, 22}, {2750, 9, 2})
  false
  iex>Elixir.Egyptian.ge({2750, 9, 2}, {2750, 5, 22})
  true

Specs

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

Examples

  iex>Elixir.Egyptian.gt({2750, 5, 22}, {2750, 5, 22})
  false
  iex>Elixir.Egyptian.gt({2750, 5, 22}, {2750, 9, 2})
  false
  iex>Elixir.Egyptian.gt({2750, 9, 2}, {2750, 5, 22})
  true

Specs

keyword() :: atom()

Returns the internal keyword of the Egyptian calendar.

Example

  iex>Elixir.Egyptian.keyword()
  :egyptian

Specs

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

Examples

  iex>Elixir.Egyptian.le({2750, 5, 22}, {2750, 5, 22})
  true
  iex>Elixir.Egyptian.le({2750, 5, 22}, {2750, 9, 2})
  true
  iex>Elixir.Egyptian.le({2750, 9, 2}, {2750, 5, 22})
  false

Specs

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

Examples

  iex>Elixir.Egyptian.lt({2750, 5, 22}, {2750, 5, 22})
  false
  iex>Elixir.Egyptian.lt({2750, 5, 22}, {2750, 9, 2})
  true
  iex>Elixir.Egyptian.lt({2750, 9, 2}, {2750, 5, 22})
  false

Specs

module() :: module()

Returns the module of the Egyptian calendar.

Example

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

month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Egyptian.month({2750, 5, 22})
  5
  iex>Elixir.Egyptian.month({2750, 5, 22}, :atom)
  :month
  iex>Elixir.Egyptian.month({2750, 5, 22}, :index)
  1
  iex>Elixir.Egyptian.month({2750, 5, 22}, :name)
  "Month"
  iex>Elixir.Egyptian.month({2750, 5, 22}, :value)
  5

Specs

name() :: atom()

Returns the internal name of the Egyptian calendar.

Example

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

Specs

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

Example

  iex>Elixir.Egyptian.range({2750, 5, 22}, {2750, 9, 2})
  730739..730839

Specs

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

Returns the start of the day in the Egyptian calendar.

Possible return values are:

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

Example

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

to_date(date, other_calendar)

View Source

Specs

to_date(egyptian_date(), module()) :: tuple()

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

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

Example

  iex>Elixir.Egyptian.to_date({2750, 5, 22}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(egyptian_date()) :: fixed()

Converts a Egyptian date tuple into a fixed day.

Example

  iex>Elixir.Egyptian.to_fixed({2750, 5, 22})
  730739
Link to this function

to_fixed(year, month, day)

View Source

Specs

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

Example

  iex>Elixir.Egyptian.to_fixed(2750, 5, 22)
  730739

Specs

to_jd(egyptian_date()) :: {number()}

Converts a Egyptian date into the equivalent Julian Day.

Example

  iex>Elixir.Egyptian.to_jd({2750, 5, 22})
  {2452163.5}

Specs

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

Example

  iex>Elixir.Egyptian.to_jd(2750, 5, 22)
  {2452163.5}

Specs

to_rata_die(egyptian_date()) :: {integer()}

Converts a Egyptian date into the equivalent RataDie date.

Example

  iex>Elixir.Egyptian.to_rata_die({2750, 5, 22})
  {730739}
Link to this function

to_rata_die(year, month, day)

View Source

Specs

to_rata_die(egyptian_year(), egyptian_month(), egyptian_day()) :: {integer()}

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

Example

  iex>Elixir.Egyptian.to_rata_die(2750, 5, 22)
  {730739}

Specs

to_unix(egyptian_date()) :: {integer()}

Converts a Egyptian date into the equivalent Unix date.

Example

  iex>Elixir.Egyptian.to_unix({2750, 5, 22})
  {1000166400}
Link to this function

to_unix(year, month, day)

View Source

Specs

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

Example

  iex>Elixir.Egyptian.to_unix(2750, 5, 22)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | egyptian_date()

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

Examples

  Elixir.Egyptian.today()
  730739
  Elixir.Egyptian.today(:fixed)
  730739
  Elixir.Egyptian.today(:date)
  {2750, 5, 22}
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Egyptian.year({2750, 5, 22})
  2750
  iex>Elixir.Egyptian.year({2750, 5, 22}, :atom)
  :year
  iex>Elixir.Egyptian.year({2750, 5, 22}, :index)
  0
  iex>Elixir.Egyptian.year({2750, 5, 22}, :name)
  "Year"
  iex>Elixir.Egyptian.year({2750, 5, 22}, :value)
  2750