French (Calendars v0.2.4) View Source

Documentation for the French calendar module.

Link to this section Summary

Functions

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

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

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

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

Compares two French dates and returns...

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

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

Returns the day field of a French date.

Returns the epoch of the French calendar.

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

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

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

Returns the number of fields in a French date

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

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

Converts a fixed day to a French date.

Converts a Julian Day into the equivalent French date.

Converts a RataDie date into the equivalent French date.

Converts a Unix date into the equivalent French date.

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

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

Returns the internal keyword of the French calendar.

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

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

Returns the module of the French calendar.

Returns the month field of a French date.

Returns the internal name of the French calendar.

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

Returns the start of the day in the French calendar.

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

Converts a French date tuple into a fixed day.

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

Converts a French date into the equivalent Julian Day.

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

Converts a French date into the equivalent RataDie date.

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

Converts a French date into the equivalent Unix date.

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

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

Returns the year field of a French date.

Link to this section Types

Specs

fixed() :: integer()

Specs

french_date() :: {french_year(), french_month(), french_day()}

Specs

french_day() :: 1..30

Specs

french_month() :: 1..13

Specs

french_year() :: integer()

Specs

t() :: french_date()

Link to this section Functions

Link to this function

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

View Source

Specs

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

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

Examples

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

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

  iex>Elixir.French.add_days(730739, 100, :date)
  {210, 3, 30}
  iex>Elixir.French.add_days(730739, -100, :date)
  {209, 9, 15}

  iex>Elixir.French.add_days({209, 12, 25}, 100)
  730839
  iex>Elixir.French.add_days({209, 12, 25}, -100)
  730639

  iex>Elixir.French.add_days({209, 12, 25}, 100, :fixed)
  730839
  iex>Elixir.French.add_days({209, 12, 25}, -100, :fixed)
  730639

  iex>Elixir.French.add_days({209, 12, 25}, 100, :date)
  {210, 3, 30}
  iex>Elixir.French.add_days({209, 12, 25}, -100, :date)
  {209, 9, 15}

Specs

as_date(fixed() | french_date()) :: french_date()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.French.as_date(730739)
  {209, 12, 25}
  iex>Elixir.French.as_date({209, 12, 25})
  {209, 12, 25}

Specs

as_fixed(fixed() | french_date()) :: fixed()

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

This is a convenience function to simplify certain function calls.

Examples

  iex>Elixir.French.as_fixed(730739)
  730739
  iex>Elixir.French.as_fixed({209, 12, 25})
  730739
Link to this function

as_type(cal_date, type \\ :fixed)

View Source

Specs

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

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

The type parameter determines the type of the returned value:

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

Examples

  iex>Elixir.French.as_type(730739)
  730739
  iex>Elixir.French.as_type(730739, :fixed)
  730739
  iex>Elixir.French.as_type(730739, :date)
  {209, 12, 25}
  iex>Elixir.French.as_type({209, 12, 25})
  730739
  iex>Elixir.French.as_type({209, 12, 25}, :fixed)
  730739
  iex>Elixir.French.as_type({209, 12, 25}, :date)
  {209, 12, 25}

Specs

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

Compares two French 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.French.compare({209, 12, 25}, {209, 12, 25})
  :eq
  iex>Elixir.French.compare({209, 12, 25}, {210, 3, 30})
  :lt
  iex>Elixir.French.compare({210, 3, 30}, {209, 12, 25})
  :gt

Specs

date(french_year(), french_month(), french_day()) :: t()

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

Example

  iex>Elixir.French.date(209, 12, 25)
  {209, 12, 25}
Link to this function

date_diff(cal_date1, cal_date2)

View Source

Specs

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

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

The dates can be given as fixed days or French 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.French.date_diff(730739, 730839)
  100
  iex>Elixir.French.date_diff(730839, 730739)
  -100
  iex>Elixir.French.date_diff({209, 12, 25}, {210, 3, 30})
  100
  iex>Elixir.French.date_diff({210, 3, 30}, {209, 12, 25})
  -100
  iex>Elixir.French.date_diff(730739, {210, 3, 30})
  100
  iex>Elixir.French.date_diff({209, 12, 25}, 730839)
  100
Link to this function

day(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.French.day({209, 12, 25})
  25
  iex>Elixir.French.day({209, 12, 25}, :atom)
  :day
  iex>Elixir.French.day({209, 12, 25}, :index)
  2
  iex>Elixir.French.day({209, 12, 25}, :name)
  "Day"
  iex>Elixir.French.day({209, 12, 25}, :value)
  25

Specs

epoch() :: number()

Returns the epoch of the French calendar.

Example

  iex>Elixir.French.epoch()
  654415

Specs

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

Examples

  iex>Elixir.French.eq({209, 12, 25}, {209, 12, 25})
  true
  iex>Elixir.French.eq({209, 12, 25}, {210, 3, 30})
  false
  iex>Elixir.French.eq({210, 3, 30}, {209, 12, 25})
  false

Specs

field_atom(integer()) :: atom()

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

Examples

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

Specs

field_atoms() :: [atom()]

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

Example

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

Specs

field_count() :: integer()

Returns the number of fields in a French date

Example

  iex>Elixir.French.field_count()
  3

Specs

field_index(atom()) :: integer()

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

Examples

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

from_date(other_date, other_calendar)

View Source

Specs

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

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

Example

  iex>Elixir.French.from_date({2001, 9, 11}, Gregorian)
  {209, 12, 25}

Specs

from_fixed(fixed()) :: french_date()

Converts a fixed day to a French date.

Example

  iex>Elixir.French.from_fixed(730739)
  {209, 12, 25}

Specs

from_jd(tuple() | number()) :: french_date()

Converts a Julian Day into the equivalent French date.

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

Examples

  iex>Elixir.French.from_jd({2452163.5})
  {209, 12, 25}
  iex>Elixir.French.from_jd(2452163.5)
  {209, 12, 25}

Specs

from_rata_die(tuple() | integer()) :: french_date()

Converts a RataDie date into the equivalent French date.

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

Examples

  iex>Elixir.French.from_rata_die({730739})
  {209, 12, 25}
  iex>Elixir.French.from_rata_die(730739)
  {209, 12, 25}

Specs

from_unix(tuple() | integer()) :: french_date()

Converts a Unix date into the equivalent French date.

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

Examples

  iex>Elixir.French.from_unix({1000166400})
  {209, 12, 25}
  iex>Elixir.French.from_unix(1000166400)
  {209, 12, 25}

Specs

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

Examples

  iex>Elixir.French.ge({209, 12, 25}, {209, 12, 25})
  true
  iex>Elixir.French.ge({209, 12, 25}, {210, 3, 30})
  false
  iex>Elixir.French.ge({210, 3, 30}, {209, 12, 25})
  true

Specs

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

Examples

  iex>Elixir.French.gt({209, 12, 25}, {209, 12, 25})
  false
  iex>Elixir.French.gt({209, 12, 25}, {210, 3, 30})
  false
  iex>Elixir.French.gt({210, 3, 30}, {209, 12, 25})
  true

Specs

keyword() :: atom()

Returns the internal keyword of the French calendar.

Example

  iex>Elixir.French.keyword()
  :french

Specs

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

Examples

  iex>Elixir.French.le({209, 12, 25}, {209, 12, 25})
  true
  iex>Elixir.French.le({209, 12, 25}, {210, 3, 30})
  true
  iex>Elixir.French.le({210, 3, 30}, {209, 12, 25})
  false

Specs

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

Examples

  iex>Elixir.French.lt({209, 12, 25}, {209, 12, 25})
  false
  iex>Elixir.French.lt({209, 12, 25}, {210, 3, 30})
  true
  iex>Elixir.French.lt({210, 3, 30}, {209, 12, 25})
  false

Specs

module() :: module()

Returns the module of the French calendar.

Example

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

month(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.French.month({209, 12, 25})
  12
  iex>Elixir.French.month({209, 12, 25}, :atom)
  :month
  iex>Elixir.French.month({209, 12, 25}, :index)
  1
  iex>Elixir.French.month({209, 12, 25}, :name)
  "Month"
  iex>Elixir.French.month({209, 12, 25}, :value)
  12

Specs

name() :: atom()

Returns the internal name of the French calendar.

Example

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

Specs

range(french_date(), french_date()) :: integer()

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

Example

  iex>Elixir.French.range({209, 12, 25}, {210, 3, 30})
  730739..730839

Specs

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

Returns the start of the day in the French calendar.

Possible return values are:

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

Example

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

to_date(date, other_calendar)

View Source

Specs

to_date(french_date(), module()) :: tuple()

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

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

Example

  iex>Elixir.French.to_date({209, 12, 25}, Gregorian)
  {2001, 9, 11}

Specs

to_fixed(french_date()) :: fixed()

Converts a French date tuple into a fixed day.

Example

  iex>Elixir.French.to_fixed({209, 12, 25})
  730739
Link to this function

to_fixed(year, month, day)

View Source

Specs

to_fixed(french_year(), french_month(), french_day()) :: fixed()

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

Example

  iex>Elixir.French.to_fixed(209, 12, 25)
  730739

Specs

to_jd(french_date()) :: {number()}

Converts a French date into the equivalent Julian Day.

Example

  iex>Elixir.French.to_jd({209, 12, 25})
  {2452163.5}

Specs

to_jd(french_year(), french_month(), french_day()) :: {number()}

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

Example

  iex>Elixir.French.to_jd(209, 12, 25)
  {2452163.5}

Specs

to_rata_die(french_date()) :: {integer()}

Converts a French date into the equivalent RataDie date.

Example

  iex>Elixir.French.to_rata_die({209, 12, 25})
  {730739}
Link to this function

to_rata_die(year, month, day)

View Source

Specs

to_rata_die(french_year(), french_month(), french_day()) :: {integer()}

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

Example

  iex>Elixir.French.to_rata_die(209, 12, 25)
  {730739}

Specs

to_unix(french_date()) :: {integer()}

Converts a French date into the equivalent Unix date.

Example

  iex>Elixir.French.to_unix({209, 12, 25})
  {1000166400}
Link to this function

to_unix(year, month, day)

View Source

Specs

to_unix(french_year(), french_month(), french_day()) :: {integer()}

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

Example

  iex>Elixir.French.to_unix(209, 12, 25)
  {1000166400}

Specs

today(:fixed | :date) :: fixed() | french_date()

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

Examples

  Elixir.French.today()
  730739
  Elixir.French.today(:fixed)
  730739
  Elixir.French.today(:date)
  {209, 12, 25}
Link to this function

year(cal_date, type \\ :value)

View Source

Specs

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

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

  iex>Elixir.French.year({209, 12, 25})
  209
  iex>Elixir.French.year({209, 12, 25}, :atom)
  :year
  iex>Elixir.French.year({209, 12, 25}, :index)
  0
  iex>Elixir.French.year({209, 12, 25}, :name)
  "Year"
  iex>Elixir.French.year({209, 12, 25}, :value)
  209