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