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