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