Julian (Calendars v0.2.4) View Source

The Julian calendar module.

Link to this section Summary

Functions

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

Adds the number of weeks to a fixed day or Julian date.

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

Returns the fixed date of Easter (Orthodox) Alt of the Julian calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns the month april of the Julian calendar.

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

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

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

Returns the month august of the Julian calendar.

Compares two Julian dates and returns...

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

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

Returns the day field of a Julian date.

Returns the ordinal day number of a fixed day or Julian date in the corresponding month.

Returns the ordinal day number of a fixed day or Julian date in the corresponding week.

Returns the ordinal day number of the fixed day or Julian date in the equivalent Julian year.

Returns the number of days in the month of a fixed day or Julian date.

Returns the number of days in the month given by the Julian year and month.

Returns the number of days in a week of the Julian calendar.

Returns the number of days in the Julian year.

Returns the number of days remaing in the month after a fixed day or Julian date.

Returns the number of days remaing after a fixed day or a Julian date in the equivalent Julian year.

Returns the month december of the Julian calendar.

Returns the fixed date of Christmas (Orthodox) of the Julian calendar in the given gregorian_year or [], if there is no such holiday in that year.

Returns the last day of the month given by a fixed day or Julian date.

Returns the last day of the month given by the Julian year and month.

Returns the end of the week of the fixed day or Julian date.

Returns the last day of the Julian year given by a fixed day or a Julian date.

Returns the epoch of the Julian calendar.

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

Returns the month february of the Julian calendar.

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

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

Returns the number of fields in a Julian date

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

Returns the weekday friday of the Julian calendar.

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

Converts a fixed day to a Julian date.

Converts a Julian Day into the equivalent Julian date.

Converts a RataDie date into the equivalent Julian date.

Converts a Unix date into the equivalent Julian date.

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

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

Returns a list of the holidays of the Julian calendar.

Returns the month january of the Julian calendar.

Returns the month july of the Julian calendar.

Returns the month june of the Julian calendar.

Returns the internal keyword of the Julian calendar.

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

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

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

Returns the month march of the Julian calendar.

Returns the month may of the Julian calendar.

Returns the average length of a Julian year.

Returns the module of the Julian calendar.

Returns the weekday monday of the Julian calendar.

Returns the month field of a Julian date.

Returns a list of the months of the Julian calendar.

Returns the number of months in the Julian year.

Returns the internal name of the Julian calendar.

Returns the month november of the Julian calendar.

Returns the month october of the Julian calendar.

Returns the fixed date of Easter (Orthodox) of the Julian calendar in the given gregorian_year or [], if there is no such holiday in that year.

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

Returns the weekday saturday of the Julian calendar.

Returns the month september of the Julian calendar.

Returns the first official use of the Julian calendar.

Returns the start of the day in the Julian calendar.

Returns the first day of the month given by a fixed day or Julian date.

Returns the first day of the month given by the Julian year and month.

Returns the start of the week of the fixed day or Julian date.

Returns the first day of the Julian year given by a fixed day or a Julian date.

Returns the weekday sunday of the Julian calendar.

Returns the weekday thursday of the Julian calendar.

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

Converts a Julian date tuple into a fixed day.

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

Converts a Julian date into the equivalent Julian Day.

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

Converts a Julian date into the equivalent RataDie date.

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

Converts a Julian date into the equivalent Unix date.

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

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

Returns the weekday tuesday of the Julian calendar.

Returns the weekday wednesday of the Julian calendar.

Returns the weekday of a fixed day or a Julian date.

Returns a list of the weekdays of the Julian calendar.

Returns the year field of a Julian date.

Link to this section Types

Specs

fixed() :: integer()

Specs

julian_date() :: {julian_year(), julian_month(), julian_day()}

Specs

julian_day() :: 1..31

Specs

julian_month() :: 1..12

Specs

julian_year() :: integer()

Specs

t() :: julian_date()

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

  iex>Elixir.Julian.add_days(730739, 100, :date)
  {2001, 12, 7}
  iex>Elixir.Julian.add_days(730739, -100, :date)
  {2001, 5, 21}

  iex>Elixir.Julian.add_days({2001, 8, 29}, 100)
  730839
  iex>Elixir.Julian.add_days({2001, 8, 29}, -100)
  730639

  iex>Elixir.Julian.add_days({2001, 8, 29}, 100, :fixed)
  730839
  iex>Elixir.Julian.add_days({2001, 8, 29}, -100, :fixed)
  730639

  iex>Elixir.Julian.add_days({2001, 8, 29}, 100, :date)
  {2001, 12, 7}
  iex>Elixir.Julian.add_days({2001, 8, 29}, -100, :date)
  {2001, 5, 21}
Link to this function

add_weeks(cal_date, weeks, type \\ :fixed)

View Source

Specs

add_weeks(fixed() | julian_date(), integer(), :fixed | :date) ::
  fixed() | julian_date()

Adds the number of weeks to a fixed day or Julian date.

If weeks is negative, the weeks will be subtracted.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.add_weeks(730739, 3)
  730760
  iex>Elixir.Julian.add_weeks(730739, -3)
  730718

  iex>Elixir.Julian.add_weeks(730739, 3, :fixed)
  730760
  iex>Elixir.Julian.add_weeks(730739, -3, :fixed)
  730718

  iex>Elixir.Julian.add_weeks(730739, 3, :date)
  {2001, 9, 19}
  iex>Elixir.Julian.add_weeks(730739, -3, :date)
  {2001, 8, 8}

  iex>Elixir.Julian.add_weeks({2001, 8, 29}, 3)
  730760
  iex>Elixir.Julian.add_weeks({2001, 8, 29}, -3)
  730718

  iex>Elixir.Julian.add_weeks({2001, 8, 29}, 3, :fixed)
  730760
  iex>Elixir.Julian.add_weeks({2001, 8, 29}, -3, :fixed)
  730718

  iex>Elixir.Julian.add_weeks({2001, 8, 29}, 3, :date)
  {2001, 9, 19}
  iex>Elixir.Julian.add_weeks({2001, 8, 29}, -3, :date)
  {2001, 8, 8}
Link to this function

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

View Source

Specs

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

Adds the number of years to a fixed year or Julian 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 Julian date.

Examples

  iex>Elixir.Julian.add_years(730739, 3)
  731834
  iex>Elixir.Julian.add_years(730739, -3)
  729643

  iex>Elixir.Julian.add_years(730739, 3, :fixed)
  731834
  iex>Elixir.Julian.add_years(730739, -3, :fixed)
  729643

  iex>Elixir.Julian.add_years(730739, 3, :date)
  {2004, 8, 28}
  iex>Elixir.Julian.add_years(730739, -3, :date)
  {1998, 8, 29}

  iex>Elixir.Julian.add_years({2001, 8, 29}, 3)
  731834
  iex>Elixir.Julian.add_years({2001, 8, 29}, -3)
  729643

  iex>Elixir.Julian.add_years({2001, 8, 29}, 3, :fixed)
  731834
  iex>Elixir.Julian.add_years({2001, 8, 29}, -3, :fixed)
  729643

  iex>Elixir.Julian.add_years({2001, 8, 29}, 3, :date)
  {2004, 8, 28}
  iex>Elixir.Julian.add_years({2001, 8, 29}, -3, :date)
  {1998, 8, 29}
Link to this function

alt_orthodox_easter(gregorian_year)

View Source

Specs

alt_orthodox_easter(Gregorian.gregorian_year()) :: fixed() | julian_date()

Returns the fixed date of Easter (Orthodox) Alt of the Julian 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 Julian date.

Example

  iex>Elixir.Julian.alt_orthodox_easter(2001)
  {2001, 4, 15}

Specs

april(:integer | :name) :: integer()

Returns the month april of the Julian 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.Julian.april()
  4
  iex>Elixir.Julian.april(:integer)
  4
  iex>Elixir.Julian.april(:name)
  "April"

Specs

as_date(fixed() | julian_date()) :: julian_date()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Julian.as_date(730739)
  {2001, 8, 29}
  iex>Elixir.Julian.as_date({2001, 8, 29})
  {2001, 8, 29}

Specs

as_fixed(fixed() | julian_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.Julian.as_fixed(730739)
  730739
  iex>Elixir.Julian.as_fixed({2001, 8, 29})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.as_type(730739)
  730739
  iex>Elixir.Julian.as_type(730739, :fixed)
  730739
  iex>Elixir.Julian.as_type(730739, :date)
  {2001, 8, 29}
  iex>Elixir.Julian.as_type({2001, 8, 29})
  730739
  iex>Elixir.Julian.as_type({2001, 8, 29}, :fixed)
  730739
  iex>Elixir.Julian.as_type({2001, 8, 29}, :date)
  {2001, 8, 29}
Link to this function

august(type \\ :integer)

View Source

Specs

august(:integer | :name) :: integer()

Returns the month august of the Julian 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.Julian.august()
  8
  iex>Elixir.Julian.august(:integer)
  8
  iex>Elixir.Julian.august(:name)
  "August"

Specs

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

Compares two Julian 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.Julian.compare({2001, 8, 29}, {2001, 8, 29})
  :eq
  iex>Elixir.Julian.compare({2001, 8, 29}, {2001, 12, 7})
  :lt
  iex>Elixir.Julian.compare({2001, 12, 7}, {2001, 8, 29})
  :gt

Specs

date(julian_year(), julian_month(), julian_day()) :: t()

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

Example

  iex>Elixir.Julian.date(2001, 8, 29)
  {2001, 8, 29}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

The dates can be given as fixed days or Julian 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.Julian.date_diff(730739, 730839)
  100
  iex>Elixir.Julian.date_diff(730839, 730739)
  -100
  iex>Elixir.Julian.date_diff({2001, 8, 29}, {2001, 12, 7})
  100
  iex>Elixir.Julian.date_diff({2001, 12, 7}, {2001, 8, 29})
  -100
  iex>Elixir.Julian.date_diff(730739, {2001, 12, 7})
  100
  iex>Elixir.Julian.date_diff({2001, 8, 29}, 730839)
  100
Link to this function

day(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Julian.day({2001, 8, 29})
  29
  iex>Elixir.Julian.day({2001, 8, 29}, :atom)
  :day
  iex>Elixir.Julian.day({2001, 8, 29}, :index)
  2
  iex>Elixir.Julian.day({2001, 8, 29}, :name)
  "Day"
  iex>Elixir.Julian.day({2001, 8, 29}, :value)
  29

Specs

day_of_month(fixed() | julian_date()) :: integer()

Returns the ordinal day number of a fixed day or Julian date in the corresponding month.

Examples

  iex>Elixir.Julian.day_of_month(730739)
  29
  iex>Elixir.Julian.day_of_month({2001, 8, 29})
  29

Specs

day_of_week(fixed() | julian_date()) :: integer()

Returns the ordinal day number of a fixed day or Julian date in the corresponding week.

Examples

  iex>Elixir.Julian.day_of_week(730739)
  2
  iex>Elixir.Julian.day_of_week({2001, 8, 29})
  2

Specs

day_of_year(fixed() | julian_date()) :: integer()

Returns the ordinal day number of the fixed day or Julian date in the equivalent Julian year.

Examples

  iex>Elixir.Julian.day_of_year(730739)
  241
  iex>Elixir.Julian.day_of_year({2001, 8, 29})
  241

Specs

days_in_month(fixed() | julian_date()) :: integer()

Returns the number of days in the month of a fixed day or Julian date.

Examples

  iex>Elixir.Julian.days_in_month(730739)
  31
  iex>Elixir.Julian.days_in_month({2001, 8, 29})
  31
Link to this function

days_in_month(year, month)

View Source

Specs

days_in_month(julian_year(), julian_month()) :: integer()

Returns the number of days in the month given by the Julian year and month.

Example

  iex>Elixir.Julian.days_in_month(2001, 8)
  31

Specs

days_in_week() :: integer()

Returns the number of days in a week of the Julian calendar.

Example

  iex>Elixir.Julian.days_in_week()
  7

Specs

days_in_year(julian_year()) :: integer()

Returns the number of days in the Julian year.

Examples

  iex>Elixir.Julian.days_in_year(2000)
  366
  iex>Elixir.Julian.days_in_year(2001)
  365
Link to this function

days_remaining_in_month(cal_date)

View Source

Specs

days_remaining_in_month(fixed() | julian_date()) :: integer()

Returns the number of days remaing in the month after a fixed day or Julian date.

Examples

  iex>Elixir.Julian.days_remaining_in_month(730739)
  2
  iex>Elixir.Julian.days_remaining_in_month({2001, 8, 29})
  2
Link to this function

days_remaining_in_year(cal_date)

View Source

Specs

days_remaining_in_year(fixed() | julian_date()) :: integer()

Returns the number of days remaing after a fixed day or a Julian date in the equivalent Julian year.

Examples

  iex>Elixir.Julian.days_remaining_in_year(730739)
  124
  iex>Elixir.Julian.days_remaining_in_year({2001, 8, 29})
  124
Link to this function

december(type \\ :integer)

View Source

Specs

december(:integer | :name) :: integer()

Returns the month december of the Julian 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.Julian.december()
  12
  iex>Elixir.Julian.december(:integer)
  12
  iex>Elixir.Julian.december(:name)
  "December"
Link to this function

eastern_orthodox_christmas(gregorian_year)

View Source

Specs

eastern_orthodox_christmas(Gregorian.gregorian_year()) ::
  fixed() | julian_date()

Returns the fixed date of Christmas (Orthodox) of the Julian 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 Julian date.

Example

  iex>Elixir.Julian.eastern_orthodox_christmas(2001)
  {2001, 1, 7}
Link to this function

end_of_month(cal_date, type \\ :fixed)

View Source

Specs

end_of_month(fixed() | julian_date(), :fixed | :date) :: fixed() | julian_date()

Returns the last day of the month given by a fixed day or Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.end_of_month(730739)
  730741
  iex>Elixir.Julian.end_of_month(730739, :fixed)
  730741
  iex>Elixir.Julian.end_of_month(730739, :date)
  {2001, 8, 31}

  iex>Elixir.Julian.end_of_month({2001, 8, 31})
  730741
  iex>Elixir.Julian.end_of_month({2001, 8, 29}, :fixed)
  730741
  iex>Elixir.Julian.end_of_month({2001, 8, 29}, :date)
  {2001, 8, 31}
Link to this function

end_of_month(year, month, type)

View Source

Specs

end_of_month(julian_year(), julian_month(), :fixed | :date) ::
  fixed() | julian_date()

Returns the last day of the month given by the Julian year and month.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.end_of_month(2001, 8, :fixed)
  730741
  iex>Elixir.Julian.end_of_month(2001, 8, :date)
  {2001, 8, 31}
Link to this function

end_of_week(cal_date, type \\ :fixed)

View Source

Specs

end_of_week(fixed() | julian_date(), :fixed | :date) :: fixed() | julian_date()

Returns the end of the week of the fixed day or Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.end_of_week(730739)
  730743
  iex>Elixir.Julian.end_of_week(730739, :fixed)
  730743
  iex>Elixir.Julian.end_of_week(730739, :date)
  {2001, 9, 2}

  iex>Elixir.Julian.end_of_week({2001, 8, 29})
  730743
  iex>Elixir.Julian.end_of_week({2001, 8, 29}, :fixed)
  730743
  iex>Elixir.Julian.end_of_week({2001, 8, 29}, :date)
  {2001, 9, 2}
Link to this function

end_of_year(cal_date, type \\ :fixed)

View Source

Specs

end_of_year(fixed() | julian_date(), :fixed | :date) :: fixed() | julian_date()

Returns the last day of the Julian year given by a fixed day or a Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.end_of_year(730739)
  730863
  iex>Elixir.Julian.end_of_year(730739, :fixed)
  730863
  iex>Elixir.Julian.end_of_year(730739, :date)
  {2001, 12, 31}

Specs

epoch() :: number()

Returns the epoch of the Julian calendar.

Example

  iex>Elixir.Julian.epoch()
  -1

Specs

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

Examples

  iex>Elixir.Julian.eq({2001, 8, 29}, {2001, 8, 29})
  true
  iex>Elixir.Julian.eq({2001, 8, 29}, {2001, 12, 7})
  false
  iex>Elixir.Julian.eq({2001, 12, 7}, {2001, 8, 29})
  false
Link to this function

february(type \\ :integer)

View Source

Specs

february(:integer | :name) :: integer()

Returns the month february of the Julian 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.Julian.february()
  2
  iex>Elixir.Julian.february(:integer)
  2
  iex>Elixir.Julian.february(:name)
  "February"

Specs

field_atom(integer()) :: atom()

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

Examples

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

Specs

field_atoms() :: [atom()]

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

Example

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

Specs

field_count() :: integer()

Returns the number of fields in a Julian date

Example

  iex>Elixir.Julian.field_count()
  3

Specs

field_index(atom()) :: integer()

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

Examples

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

friday(type \\ :integer)

View Source

Specs

friday(:integer | :name) :: integer()

Returns the weekday friday of the Julian 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.Julian.friday()
  5
  iex>Elixir.Julian.friday(:integer)
  5
  iex>Elixir.Julian.friday(:name)
  "Friday"
Link to this function

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

  iex>Elixir.Julian.from_date({2001, 9, 11}, Gregorian)
  {2001, 8, 29}

Specs

from_fixed(fixed()) :: julian_date()

Converts a fixed day to a Julian date.

Example

  iex>Elixir.Julian.from_fixed(730739)
  {2001, 8, 29}

Specs

from_jd(tuple() | number()) :: julian_date()

Converts a Julian Day into the equivalent Julian date.

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

Examples

  iex>Elixir.Julian.from_jd({2452163.5})
  {2001, 8, 29}
  iex>Elixir.Julian.from_jd(2452163.5)
  {2001, 8, 29}

Specs

from_rata_die(tuple() | integer()) :: julian_date()

Converts a RataDie date into the equivalent Julian date.

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

Examples

  iex>Elixir.Julian.from_rata_die({730739})
  {2001, 8, 29}
  iex>Elixir.Julian.from_rata_die(730739)
  {2001, 8, 29}

Specs

from_unix(tuple() | integer()) :: julian_date()

Converts a Unix date into the equivalent Julian date.

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

Examples

  iex>Elixir.Julian.from_unix({1000166400})
  {2001, 8, 29}
  iex>Elixir.Julian.from_unix(1000166400)
  {2001, 8, 29}

Specs

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

Examples

  iex>Elixir.Julian.ge({2001, 8, 29}, {2001, 8, 29})
  true
  iex>Elixir.Julian.ge({2001, 8, 29}, {2001, 12, 7})
  false
  iex>Elixir.Julian.ge({2001, 12, 7}, {2001, 8, 29})
  true

Specs

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

Examples

  iex>Elixir.Julian.gt({2001, 8, 29}, {2001, 8, 29})
  false
  iex>Elixir.Julian.gt({2001, 8, 29}, {2001, 12, 7})
  false
  iex>Elixir.Julian.gt({2001, 12, 7}, {2001, 8, 29})
  true

Returns a list of the holidays of the Julian 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.Julian.holidays()
  ["Christmas (Orthodox)", "Easter (Orthodox)", "Easter (Orthodox) Alt"]
  iex>Elixir.Julian.holidays(:atom)
  [:eastern_orthodox_christmas, :orthodox_easter, :alt_orthodox_easter]
  iex>Elixir.Julian.holidays(:name)
  ["Christmas (Orthodox)", "Easter (Orthodox)", "Easter (Orthodox) Alt"]
Link to this function

january(type \\ :integer)

View Source

Specs

january(:integer | :name) :: integer()

Returns the month january of the Julian 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.Julian.january()
  1
  iex>Elixir.Julian.january(:integer)
  1
  iex>Elixir.Julian.january(:name)
  "January"

Specs

july(:integer | :name) :: integer()

Returns the month july of the Julian 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.Julian.july()
  7
  iex>Elixir.Julian.july(:integer)
  7
  iex>Elixir.Julian.july(:name)
  "July"

Specs

june(:integer | :name) :: integer()

Returns the month june of the Julian 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.Julian.june()
  6
  iex>Elixir.Julian.june(:integer)
  6
  iex>Elixir.Julian.june(:name)
  "June"

Specs

keyword() :: atom()

Returns the internal keyword of the Julian calendar.

Example

  iex>Elixir.Julian.keyword()
  :julian

Specs

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

Examples

  iex>Elixir.Julian.le({2001, 8, 29}, {2001, 8, 29})
  true
  iex>Elixir.Julian.le({2001, 8, 29}, {2001, 12, 7})
  true
  iex>Elixir.Julian.le({2001, 12, 7}, {2001, 8, 29})
  false

Specs

leap_year?(julian_year()) :: boolean()

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

Examples

  iex>Elixir.Julian.leap_year?(2000)
  true
  iex>Elixir.Julian.leap_year?(2001)
  false
  iex>Elixir.Julian.leap_year?(2002)
  false
  iex>Elixir.Julian.leap_year?(2003)
  false

Specs

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

Examples

  iex>Elixir.Julian.lt({2001, 8, 29}, {2001, 8, 29})
  false
  iex>Elixir.Julian.lt({2001, 8, 29}, {2001, 12, 7})
  true
  iex>Elixir.Julian.lt({2001, 12, 7}, {2001, 8, 29})
  false

Specs

march(:integer | :name) :: integer()

Returns the month march of the Julian 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.Julian.march()
  3
  iex>Elixir.Julian.march(:integer)
  3
  iex>Elixir.Julian.march(:name)
  "March"

Specs

may(:integer | :name) :: integer()

Returns the month may of the Julian 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.Julian.may()
  5
  iex>Elixir.Julian.may(:integer)
  5
  iex>Elixir.Julian.may(:name)
  "May"

Specs

mean_year() :: number()

Returns the average length of a Julian year.

Example

  iex>Elixir.Julian.mean_year()
  365.25

Specs

module() :: module()

Returns the module of the Julian calendar.

Example

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

monday(type \\ :integer)

View Source

Specs

monday(:integer | :name) :: integer()

Returns the weekday monday of the Julian 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.Julian.monday()
  1
  iex>Elixir.Julian.monday(:integer)
  1
  iex>Elixir.Julian.monday(:name)
  "Monday"
Link to this function

month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Julian.month({2001, 8, 29})
  8
  iex>Elixir.Julian.month({2001, 8, 29}, :atom)
  :month
  iex>Elixir.Julian.month({2001, 8, 29}, :index)
  1
  iex>Elixir.Julian.month({2001, 8, 29}, :name)
  "Month"
  iex>Elixir.Julian.month({2001, 8, 29}, :value)
  8

Specs

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

Returns a list of the months of the Julian 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.Julian.months()
  ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  iex>Elixir.Julian.months(:integer)
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  iex>Elixir.Julian.months(:atom)
  [:january, :february, :march, :april, :may, :june, :july, :august, :september, :october, :november, :december]
  iex>Elixir.Julian.months(:name)
  ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

Specs

months_in_year(julian_year()) :: integer()

Returns the number of months in the Julian year.

Example

  iex>Elixir.Julian.months_in_year(730739)
  12

Specs

name() :: atom()

Returns the internal name of the Julian calendar.

Example

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

november(type \\ :integer)

View Source

Specs

november(:integer | :name) :: integer()

Returns the month november of the Julian 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.Julian.november()
  11
  iex>Elixir.Julian.november(:integer)
  11
  iex>Elixir.Julian.november(:name)
  "November"
Link to this function

october(type \\ :integer)

View Source

Specs

october(:integer | :name) :: integer()

Returns the month october of the Julian 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.Julian.october()
  10
  iex>Elixir.Julian.october(:integer)
  10
  iex>Elixir.Julian.october(:name)
  "October"
Link to this function

orthodox_easter(gregorian_year)

View Source

Specs

orthodox_easter(Gregorian.gregorian_year()) :: fixed() | julian_date()

Returns the fixed date of Easter (Orthodox) of the Julian 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 Julian date.

Example

  iex>Elixir.Julian.orthodox_easter(2001)
  {2001, 4, 15}

Specs

range(julian_date(), julian_date()) :: integer()

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

Example

  iex>Elixir.Julian.range({2001, 8, 29}, {2001, 12, 7})
  730739..730839
Link to this function

saturday(type \\ :integer)

View Source

Specs

saturday(:integer | :name) :: integer()

Returns the weekday saturday of the Julian 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.Julian.saturday()
  6
  iex>Elixir.Julian.saturday(:integer)
  6
  iex>Elixir.Julian.saturday(:name)
  "Saturday"
Link to this function

september(type \\ :integer)

View Source

Specs

september(:integer | :name) :: integer()

Returns the month september of the Julian 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.Julian.september()
  9
  iex>Elixir.Julian.september(:integer)
  9
  iex>Elixir.Julian.september(:name)
  "September"
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 Julian calendar.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.start_of_calendar()
  -16803
  iex>Elixir.Julian.start_of_calendar(:fixed)
  -16803
  iex>Elixir.Julian.start_of_calendar(:date)
  {-46, 1, 1}

Specs

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

Returns the start of the day in the Julian calendar.

Possible return values are:

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

Example

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

start_of_month(cal_date, type \\ :fixed)

View Source

Specs

start_of_month(fixed() | julian_date(), :fixed | :date) ::
  fixed() | julian_date()

Returns the first day of the month given by a fixed day or Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.start_of_month(730711)
  730711
  iex>Elixir.Julian.start_of_month(730711, :fixed)
  730711
  iex>Elixir.Julian.start_of_month(730711, :date)
  {2001, 8, 1}

  iex>Elixir.Julian.start_of_month({2001, 8, 1})
  730711
  iex>Elixir.Julian.start_of_month({2001, 8, 1}, :fixed)
  730711
  iex>Elixir.Julian.start_of_month({2001, 8, 1}, :date)
  {2001, 8, 1}
Link to this function

start_of_month(year, month, type)

View Source

Specs

start_of_month(julian_year(), julian_month(), :fixed | :date) ::
  fixed() | julian_date()

Returns the first day of the month given by the Julian year and month.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.start_of_month(2001, 8, :fixed)
  730711
  iex>Elixir.Julian.start_of_month(2001, 8, :date)
  {2001, 8, 1}
Link to this function

start_of_week(cal_date, type \\ :fixed)

View Source

Specs

start_of_week(fixed() | julian_date(), :fixed | :date) ::
  fixed() | julian_date()

Returns the start of the week of the fixed day or Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.start_of_week(730739)
  730737
  iex>Elixir.Julian.start_of_week(730739, :fixed)
  730737
  iex>Elixir.Julian.start_of_week(730739, :date)
  {2001, 8, 27}

  iex>Elixir.Julian.start_of_week({2001, 8, 29})
  730737
  iex>Elixir.Julian.start_of_week({2001, 8, 29}, :fixed)
  730737
  iex>Elixir.Julian.start_of_week({2001, 8, 29}, :date)
  {2001, 8, 27}
Link to this function

start_of_year(cal_date, type \\ :fixed)

View Source

Specs

start_of_year(fixed() | julian_date(), :fixed | :date) ::
  fixed() | julian_date()

Returns the first day of the Julian year given by a fixed day or a Julian date.

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.Julian.start_of_year(730739)
  730499
  iex>Elixir.Julian.start_of_year(730739, :fixed)
  730499
  iex>Elixir.Julian.start_of_year(730739, :date)
  {2001, 1, 1}
Link to this function

sunday(type \\ :integer)

View Source

Specs

sunday(:integer | :name) :: integer()

Returns the weekday sunday of the Julian 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.Julian.sunday()
  0
  iex>Elixir.Julian.sunday(:integer)
  0
  iex>Elixir.Julian.sunday(:name)
  "Sunday"
Link to this function

thursday(type \\ :integer)

View Source

Specs

thursday(:integer | :name) :: integer()

Returns the weekday thursday of the Julian 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.Julian.thursday()
  4
  iex>Elixir.Julian.thursday(:integer)
  4
  iex>Elixir.Julian.thursday(:name)
  "Thursday"
Link to this function

to_date(date, other_calendar)

View Source

Specs

to_date(julian_date(), module()) :: tuple()

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

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

Example

  iex>Elixir.Julian.to_date({2001, 8, 29}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(julian_date()) :: fixed()

Converts a Julian date tuple into a fixed day.

Example

  iex>Elixir.Julian.to_fixed({2001, 8, 29})
  730739
Link to this function

to_fixed(year, month, day)

View Source

Specs

to_fixed(julian_year(), julian_month(), julian_day()) :: fixed()

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

Example

  iex>Elixir.Julian.to_fixed(2001, 8, 29)
  730739

Specs

to_jd(julian_date()) :: {number()}

Converts a Julian date into the equivalent Julian Day.

Example

  iex>Elixir.Julian.to_jd({2001, 8, 29})
  {2452163.5}

Specs

to_jd(julian_year(), julian_month(), julian_day()) :: {number()}

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

Example

  iex>Elixir.Julian.to_jd(2001, 8, 29)
  {2452163.5}

Specs

to_rata_die(julian_date()) :: {integer()}

Converts a Julian date into the equivalent RataDie date.

Example

  iex>Elixir.Julian.to_rata_die({2001, 8, 29})
  {730739}
Link to this function

to_rata_die(year, month, day)

View Source

Specs

to_rata_die(julian_year(), julian_month(), julian_day()) :: {integer()}

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

Example

  iex>Elixir.Julian.to_rata_die(2001, 8, 29)
  {730739}

Specs

to_unix(julian_date()) :: {integer()}

Converts a Julian date into the equivalent Unix date.

Example

  iex>Elixir.Julian.to_unix({2001, 8, 29})
  {1000166400}
Link to this function

to_unix(year, month, day)

View Source

Specs

to_unix(julian_year(), julian_month(), julian_day()) :: {integer()}

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

Example

  iex>Elixir.Julian.to_unix(2001, 8, 29)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | julian_date()

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

Examples

  Elixir.Julian.today()
  730739
  Elixir.Julian.today(:fixed)
  730739
  Elixir.Julian.today(:date)
  {2001, 8, 29}
Link to this function

tuesday(type \\ :integer)

View Source

Specs

tuesday(:integer | :name) :: integer()

Returns the weekday tuesday of the Julian 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.Julian.tuesday()
  2
  iex>Elixir.Julian.tuesday(:integer)
  2
  iex>Elixir.Julian.tuesday(:name)
  "Tuesday"
Link to this function

wednesday(type \\ :integer)

View Source

Specs

wednesday(:integer | :name) :: integer()

Returns the weekday wednesday of the Julian 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.Julian.wednesday()
  3
  iex>Elixir.Julian.wednesday(:integer)
  3
  iex>Elixir.Julian.wednesday(:name)
  "Wednesday"
Link to this function

weekday(cal_date, type \\ :integer)

View Source

Specs

weekday(fixed() | julian_date(), :atom | :integer | :name) ::
  integer() | atom() | String.t()

Returns the weekday of a fixed day or a Julian date.

The type parameter determines the type of the returned weekday:

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

Examples

  iex>Elixir.Julian.weekday(730739)
  2
  iex>Elixir.Julian.weekday(730739, :integer)
  2
  iex>Elixir.Julian.weekday(730739, :atom)
  :tuesday
  iex>Elixir.Julian.weekday(730739, :name)
  "Tuesday"

  iex>Elixir.Julian.weekday({2001, 8, 29})
  2
  iex>Elixir.Julian.weekday({2001, 8, 29}, :integer)
  2
  iex>Elixir.Julian.weekday({2001, 8, 29}, :atom)
  :tuesday
  iex>Elixir.Julian.weekday({2001, 8, 29}, :name)
  "Tuesday"

Returns a list of the weekdays of the Julian 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.Julian.weekdays()
  ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  iex>Elixir.Julian.weekdays(:integer)
  [0, 1, 2, 3, 4, 5, 6]
  iex>Elixir.Julian.weekdays(:atom)
  [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]
  iex>Elixir.Julian.weekdays(:name)
  ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.Julian.year({2001, 8, 29})
  2001
  iex>Elixir.Julian.year({2001, 8, 29}, :atom)
  :year
  iex>Elixir.Julian.year({2001, 8, 29}, :index)
  0
  iex>Elixir.Julian.year({2001, 8, 29}, :name)
  "Year"
  iex>Elixir.Julian.year({2001, 8, 29}, :value)
  2001