Coptic (Calendars v0.2.4) View Source
Documentation for the Coptic calendar module.
Link to this section Summary
Functions
Adds the number of days
to a fixed day or Coptic date.
Returns a fixed day or Coptic date as a Coptic date.
Returns a fixed day or Coptic date as a fixed day.
Returns a fixed day or Coptic date either as a fixed day or a Coptic date.
Compares two Coptic dates and returns...
Returns the fixed date of Coptic Christmas
of the
Coptic calendar in the given gregorian_year
or []
,
if there is no such holiday in that year.
Returns a Coptic date from its fields year, month, day
.
Returns the difference (= number of days) between two Coptic dates.
Returns the day
field of a Coptic date.
Returns the epoch of the Coptic calendar.
Returns true if Coptic date1
is equal Coptic date2
, otherwise false.
Returns the name of the field atom in a Coptic date at field_index
.
Returns a list of the field atoms (names) of a Coptic date.
Returns the number of fields in a Coptic date
Returns the index (= position) of the field_atom
in a Coptic date.
Converts the other_date
of the other_calendar
into the equivalent date of the Coptic calendar.
Converts a fixed day to a Coptic
date.
Converts a Julian Day into the equivalent Coptic date.
Converts a RataDie date into the equivalent Coptic date.
Converts a Unix date into the equivalent Coptic date.
Returns true if Coptic date1
is greater (= later) than or equal Coptic date2
, otherwise false.
Returns true if Coptic date1
is greater (= later) than Coptic date2
, otherwise false.
Returns a list of the holidays of the Coptic calendar.
Returns the internal keyword of the Coptic calendar.
Returns true if Coptic date1
is smaller (= earlier) than or equal Coptic date2
, otherwise false.
Returns true if Coptic date1
is smaller (= earlier) than Coptic date2
, otherwise false.
Returns the module of the Coptic calendar.
Returns the month
field of a Coptic date.
Returns the internal name of the Coptic calendar.
Returns the distance between two Coptic dates as a range of fixed days.
Returns the start of the day in the Coptic calendar.
Converts a Coptic date
into the equivalent date
of the other_calendar
.
Converts a Coptic date tuple into a fixed day.
Converts a Coptic date given by year, month, day
into a fixed day.
Converts a Coptic date into the equivalent Julian Day.
Converts a Coptic date given by year, month, day
into the equivalent Julian Day.
Converts a Coptic date into the equivalent RataDie date.
Converts a Coptic date given by year, month, day
into the equivalent RataDie date.
Converts a Coptic date into the equivalent Unix date.
Converts a Coptic date given by year, month, day
into the equivalent Unix date.
Returns the current date either as a fixed day or a Coptic date.
Returns the year
field of a Coptic date.
Link to this section Types
Specs
coptic_date() :: {coptic_year(), coptic_month(), coptic_day()}
Specs
coptic_day() :: 1..31
Specs
coptic_month() :: 1..13
Specs
coptic_year() :: integer()
Specs
fixed() :: integer()
Specs
t() :: coptic_date()
Link to this section Functions
Specs
add_days(fixed() | coptic_date(), integer(), :fixed | :date) :: fixed() | coptic_date()
Adds the number of days
to a fixed day or Coptic 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 Coptic date.
Examples
iex>Elixir.Coptic.add_days(730739, 100)
730839
iex>Elixir.Coptic.add_days(730739, -100)
730639
iex>Elixir.Coptic.add_days(730739, 100, :fixed)
730839
iex>Elixir.Coptic.add_days(730739, -100, :fixed)
730639
iex>Elixir.Coptic.add_days(730739, 100, :date)
{1718, 4, 11}
iex>Elixir.Coptic.add_days(730739, -100, :date)
{1717, 9, 26}
iex>Elixir.Coptic.add_days({1718, 1, 1}, 100)
730839
iex>Elixir.Coptic.add_days({1718, 1, 1}, -100)
730639
iex>Elixir.Coptic.add_days({1718, 1, 1}, 100, :fixed)
730839
iex>Elixir.Coptic.add_days({1718, 1, 1}, -100, :fixed)
730639
iex>Elixir.Coptic.add_days({1718, 1, 1}, 100, :date)
{1718, 4, 11}
iex>Elixir.Coptic.add_days({1718, 1, 1}, -100, :date)
{1717, 9, 26}
Specs
as_date(fixed() | coptic_date()) :: coptic_date()
Returns a fixed day or Coptic date as a Coptic date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Coptic.as_date(730739)
{1718, 1, 1}
iex>Elixir.Coptic.as_date({1718, 1, 1})
{1718, 1, 1}
Specs
as_fixed(fixed() | coptic_date()) :: fixed()
Returns a fixed day or Coptic date as a fixed day.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Coptic.as_fixed(730739)
730739
iex>Elixir.Coptic.as_fixed({1718, 1, 1})
730739
Specs
as_type(fixed() | coptic_date(), :fixed | :date) :: fixed() | coptic_date()
Returns a fixed day or Coptic date either as a fixed day or a Coptic date.
The type
parameter determines the type of the returned value:
:fixed
returns a fixed day (default),:date
returns a Coptic date.
Examples
iex>Elixir.Coptic.as_type(730739)
730739
iex>Elixir.Coptic.as_type(730739, :fixed)
730739
iex>Elixir.Coptic.as_type(730739, :date)
{1718, 1, 1}
iex>Elixir.Coptic.as_type({1718, 1, 1})
730739
iex>Elixir.Coptic.as_type({1718, 1, 1}, :fixed)
730739
iex>Elixir.Coptic.as_type({1718, 1, 1}, :date)
{1718, 1, 1}
Specs
compare(coptic_date(), coptic_date()) :: :lt | :eq | :gt
Compares two Coptic dates and returns...
:lt
ifdate1
is smaller (= earlier) thandate2
,:eq
ifdate1
is equaldate2
,:gt
ifdate1
is larger (= later) thandate2
.
Examples
iex>Elixir.Coptic.compare({1718, 1, 1}, {1718, 1, 1})
:eq
iex>Elixir.Coptic.compare({1718, 1, 1}, {1718, 4, 11})
:lt
iex>Elixir.Coptic.compare({1718, 4, 11}, {1718, 1, 1})
:gt
Specs
coptic_christmas(Gregorian.gregorian_year()) :: fixed() | coptic_date()
Returns the fixed date of Coptic Christmas
of the
Coptic 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 Coptic date.
Example
iex>Elixir.Coptic.coptic_christmas(2001)
{2001, 1, 7}
Specs
date(coptic_year(), coptic_month(), coptic_day()) :: t()
Returns a Coptic date from its fields year, month, day
.
Example
iex>Elixir.Coptic.date(1718, 1, 1)
{1718, 1, 1}
Specs
date_diff(fixed() | coptic_date(), fixed() | coptic_date()) :: integer()
Returns the difference (= number of days) between two Coptic dates.
The dates can be given as fixed days or Coptic 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.Coptic.date_diff(730739, 730839)
100
iex>Elixir.Coptic.date_diff(730839, 730739)
-100
iex>Elixir.Coptic.date_diff({1718, 1, 1}, {1718, 4, 11})
100
iex>Elixir.Coptic.date_diff({1718, 4, 11}, {1718, 1, 1})
-100
iex>Elixir.Coptic.date_diff(730739, {1718, 4, 11})
100
iex>Elixir.Coptic.date_diff({1718, 1, 1}, 730839)
100
Specs
day(fixed() | coptic_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the day
field of a Coptic 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.Coptic.day(730739)
1
iex>Elixir.Coptic.day(730739, :atom)
:day
iex>Elixir.Coptic.day(730739, :index)
2
iex>Elixir.Coptic.day(730739, :name)
"Day"
iex>Elixir.Coptic.day(730739, :value)
1
iex>Elixir.Coptic.day({1718, 1, 1})
1
iex>Elixir.Coptic.day({1718, 1, 1}, :atom)
:day
iex>Elixir.Coptic.day({1718, 1, 1}, :index)
2
iex>Elixir.Coptic.day({1718, 1, 1}, :name)
"Day"
iex>Elixir.Coptic.day({1718, 1, 1}, :value)
1
Specs
epoch() :: number()
Returns the epoch of the Coptic calendar.
Example
iex>Elixir.Coptic.epoch()
103605
Specs
eq(coptic_date(), coptic_date()) :: boolean()
Returns true if Coptic date1
is equal Coptic date2
, otherwise false.
Examples
iex>Elixir.Coptic.eq({1718, 1, 1}, {1718, 1, 1})
true
iex>Elixir.Coptic.eq({1718, 1, 1}, {1718, 4, 11})
false
iex>Elixir.Coptic.eq({1718, 4, 11}, {1718, 1, 1})
false
Specs
Returns the name of the field atom in a Coptic date at field_index
.
Examples
iex>Elixir.Coptic.field_atom(0)
:year
iex>Elixir.Coptic.field_atom(1)
:month
iex>Elixir.Coptic.field_atom(2)
:day
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a Coptic date.
Example
iex>Elixir.Coptic.field_atoms()
[:year, :month, :day]
Specs
field_count() :: integer()
Returns the number of fields in a Coptic date
Example
iex>Elixir.Coptic.field_count()
3
Specs
Returns the index (= position) of the field_atom
in a Coptic date.
Examples
iex>Elixir.Coptic.field_index(:year)
0
iex>Elixir.Coptic.field_index(:month)
1
iex>Elixir.Coptic.field_index(:day)
2
Specs
Converts the other_date
of the other_calendar
into the equivalent date of the Coptic calendar.
Example
iex>Elixir.Coptic.from_date({2001, 9, 11}, Gregorian)
{1718, 1, 1}
Specs
from_fixed(fixed()) :: coptic_date()
Converts a fixed day to a Coptic
date.
Example
iex>Elixir.Coptic.from_fixed(730739)
{1718, 1, 1}
Specs
from_jd(tuple() | number()) :: coptic_date()
Converts a Julian Day into the equivalent Coptic date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.Coptic.from_jd({2452163.5})
{1718, 1, 1}
iex>Elixir.Coptic.from_jd(2452163.5)
{1718, 1, 1}
Specs
from_rata_die(tuple() | integer()) :: coptic_date()
Converts a RataDie date into the equivalent Coptic date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.Coptic.from_rata_die({730739})
{1718, 1, 1}
iex>Elixir.Coptic.from_rata_die(730739)
{1718, 1, 1}
Specs
from_unix(tuple() | integer()) :: coptic_date()
Converts a Unix date into the equivalent Coptic date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.Coptic.from_unix({1000166400})
{1718, 1, 1}
iex>Elixir.Coptic.from_unix(1000166400)
{1718, 1, 1}
Specs
ge(coptic_date(), coptic_date()) :: boolean()
Returns true if Coptic date1
is greater (= later) than or equal Coptic date2
, otherwise false.
Examples
iex>Elixir.Coptic.ge({1718, 1, 1}, {1718, 1, 1})
true
iex>Elixir.Coptic.ge({1718, 1, 1}, {1718, 4, 11})
false
iex>Elixir.Coptic.ge({1718, 4, 11}, {1718, 1, 1})
true
Specs
gt(coptic_date(), coptic_date()) :: boolean()
Returns true if Coptic date1
is greater (= later) than Coptic date2
, otherwise false.
Examples
iex>Elixir.Coptic.gt({1718, 1, 1}, {1718, 1, 1})
false
iex>Elixir.Coptic.gt({1718, 1, 1}, {1718, 4, 11})
false
iex>Elixir.Coptic.gt({1718, 4, 11}, {1718, 1, 1})
true
Returns a list of the holidays of the Coptic 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.Coptic.holidays()
["Coptic Christmas"]
iex>Elixir.Coptic.holidays(:atom)
[:coptic_christmas]
iex>Elixir.Coptic.holidays(:name)
["Coptic Christmas"]
Specs
keyword() :: atom()
Returns the internal keyword of the Coptic calendar.
Example
iex>Elixir.Coptic.keyword()
:coptic
Specs
le(coptic_date(), coptic_date()) :: boolean()
Returns true if Coptic date1
is smaller (= earlier) than or equal Coptic date2
, otherwise false.
Examples
iex>Elixir.Coptic.le({1718, 1, 1}, {1718, 1, 1})
true
iex>Elixir.Coptic.le({1718, 1, 1}, {1718, 4, 11})
true
iex>Elixir.Coptic.le({1718, 4, 11}, {1718, 1, 1})
false
Specs
lt(coptic_date(), coptic_date()) :: boolean()
Returns true if Coptic date1
is smaller (= earlier) than Coptic date2
, otherwise false.
Examples
iex>Elixir.Coptic.lt({1718, 1, 1}, {1718, 1, 1})
false
iex>Elixir.Coptic.lt({1718, 1, 1}, {1718, 4, 11})
true
iex>Elixir.Coptic.lt({1718, 4, 11}, {1718, 1, 1})
false
Specs
module() :: module()
Returns the module of the Coptic calendar.
Example
iex>Elixir.Coptic.module()
Coptic
Specs
month(fixed() | coptic_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the month
field of a Coptic 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.Coptic.month(730739)
1
iex>Elixir.Coptic.month(730739, :atom)
:month
iex>Elixir.Coptic.month(730739, :index)
1
iex>Elixir.Coptic.month(730739, :name)
"Month"
iex>Elixir.Coptic.month(730739, :value)
1
iex>Elixir.Coptic.month({1718, 1, 1})
1
iex>Elixir.Coptic.month({1718, 1, 1}, :atom)
:month
iex>Elixir.Coptic.month({1718, 1, 1}, :index)
1
iex>Elixir.Coptic.month({1718, 1, 1}, :name)
"Month"
iex>Elixir.Coptic.month({1718, 1, 1}, :value)
1
Specs
name() :: atom()
Returns the internal name of the Coptic calendar.
Example
iex>Elixir.Coptic.name()
"Coptic"
Specs
range(coptic_date(), coptic_date()) :: integer()
Returns the distance between two Coptic dates as a range of fixed days.
Example
iex>Elixir.Coptic.range({1718, 1, 1}, {1718, 4, 11})
730739..730839
Specs
start_of_day() :: :midnight | :sunset | :sunrise | :noon
Returns the start of the day in the Coptic calendar.
Possible return values are:
:midnight
,:noon
,:sunrise
,:sunset
,
Example
iex>Elixir.Coptic.start_of_day()
:midnight
Specs
to_date(coptic_date(), module()) :: tuple()
Converts a Coptic date
into the equivalent date
of the other_calendar
.
For the following example to work the Gregorian calendar must be available.
Example
iex>Elixir.Coptic.to_date({1718, 1, 1}, Gregorian)
{2001, 9, 11}
Specs
to_fixed(coptic_date()) :: fixed()
Converts a Coptic date tuple into a fixed day.
Example
iex>Elixir.Coptic.to_fixed({1718, 1, 1})
730739
Specs
to_fixed(coptic_year(), coptic_month(), coptic_day()) :: fixed()
Converts a Coptic date given by year, month, day
into a fixed day.
Example
iex>Elixir.Coptic.to_fixed(1718, 1, 1)
730739
Specs
to_jd(coptic_date()) :: {number()}
Converts a Coptic date into the equivalent Julian Day.
Example
iex>Elixir.Coptic.to_jd({1718, 1, 1})
{2452163.5}
Specs
to_jd(coptic_year(), coptic_month(), coptic_day()) :: {number()}
Converts a Coptic date given by year, month, day
into the equivalent Julian Day.
Example
iex>Elixir.Coptic.to_jd(1718, 1, 1)
{2452163.5}
Specs
to_rata_die(coptic_date()) :: {integer()}
Converts a Coptic date into the equivalent RataDie date.
Example
iex>Elixir.Coptic.to_rata_die({1718, 1, 1})
{730739}
Specs
to_rata_die(coptic_year(), coptic_month(), coptic_day()) :: {integer()}
Converts a Coptic date given by year, month, day
into the equivalent RataDie date.
Example
iex>Elixir.Coptic.to_rata_die(1718, 1, 1)
{730739}
Specs
to_unix(coptic_date()) :: {integer()}
Converts a Coptic date into the equivalent Unix date.
Example
iex>Elixir.Coptic.to_unix({1718, 1, 1})
{1000166400}
Specs
to_unix(coptic_year(), coptic_month(), coptic_day()) :: {integer()}
Converts a Coptic date given by year, month, day
into the equivalent Unix date.
Example
iex>Elixir.Coptic.to_unix(1718, 1, 1)
{1000166400}
Specs
today(:fixed | :date) :: fixed() | coptic_date()
Returns the current date either as a fixed day or a Coptic 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 Coptic date.
Examples
Elixir.Coptic.today()
730739
Elixir.Coptic.today(:fixed)
730739
Elixir.Coptic.today(:date)
{1718, 1, 1}
Specs
year(fixed() | coptic_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the year
field of a Coptic 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.Coptic.year(730739)
1718
iex>Elixir.Coptic.year(730739, :atom)
:year
iex>Elixir.Coptic.year(730739, :index)
0
iex>Elixir.Coptic.year(730739, :name)
"Year"
iex>Elixir.Coptic.year(730739, :value)
1718
iex>Elixir.Coptic.year({1718, 1, 1})
1718
iex>Elixir.Coptic.year({1718, 1, 1}, :atom)
:year
iex>Elixir.Coptic.year({1718, 1, 1}, :index)
0
iex>Elixir.Coptic.year({1718, 1, 1}, :name)
"Year"
iex>Elixir.Coptic.year({1718, 1, 1}, :value)
1718