Persian (Calendars v0.2.4) View Source
The Persian
calendar module.
Link to this section Summary
Functions
Returns the month aban
of the Persian
calendar.
Adds the number of days
to a fixed day or Persian date.
Returns a fixed day or Persian date as a Persian date.
Returns a fixed day or Persian date as a fixed day.
Returns a fixed day or Persian date either as a fixed day or a Persian date.
Returns the month azar
of the Persian
calendar.
Returns the month bahman
of the Persian
calendar.
Returns a list of the Calixir functions of the Persian calendar.
Compares two Persian dates and returns...
Returns a Persian date from its fields year, month, day
.
Returns the difference (= number of days) between two Persian dates.
Returns the day
field of a Persian date.
Returns the month dey
of the Persian
calendar.
Returns the epoch of the Persian calendar.
Returns true if Persian date1
is equal Persian date2
, otherwise false.
Returns the month esfand
of the Persian
calendar.
Returns the month farvardin
of the Persian
calendar.
Returns the name of the field atom in a Persian date at field_index
.
Returns a list of the field atoms (names) of a Persian date.
Returns the number of fields in a Persian date
Returns the index (= position) of the field_atom
in a Persian date.
Converts the other_date
of the other_calendar
into the equivalent date of the Persian calendar.
Converts a fixed day to a Persian
date.
Converts a Julian Day into the equivalent Persian date.
Converts a RataDie date into the equivalent Persian date.
Converts a Unix date into the equivalent Persian date.
Returns true if Persian date1
is greater (= later) than or equal Persian date2
, otherwise false.
Returns true if Persian date1
is greater (= later) than Persian date2
, otherwise false.
Returns a list of the holidays of the Persian calendar.
Returns the internal keyword of the Persian calendar.
Returns the month khordad
of the Persian
calendar.
Returns true if Persian date1
is smaller (= earlier) than or equal Persian date2
, otherwise false.
Returns true if Persian date1
is smaller (= earlier) than Persian date2
, otherwise false.
Returns the month mehr
of the Persian
calendar.
Returns the module of the Persian calendar.
Returns the month
field of a Persian date.
Returns a list of the months of the Persian calendar.
Returns the month mordad
of the Persian
calendar.
Returns the internal name of the Persian calendar.
Returns the fixed date of Nowruz
of the
Persian calendar in the given gregorian_year
or []
,
if there is no such holiday in that year.
Returns the month ordibehesht
of the Persian
calendar.
Returns the distance between two Persian dates as a range of fixed days.
Returns the month shahrivar
of the Persian
calendar.
Returns the start of the day in the Persian calendar.
Returns the month tir
of the Persian
calendar.
Converts a Persian date
into the equivalent date
of the other_calendar
.
Converts a Persian date tuple into a fixed day.
Converts a Persian date given by year, month, day
into a fixed day.
Converts a Persian date into the equivalent Julian Day.
Converts a Persian date given by year, month, day
into the equivalent Julian Day.
Converts a Persian date into the equivalent RataDie date.
Converts a Persian date given by year, month, day
into the equivalent RataDie date.
Converts a Persian date into the equivalent Unix date.
Converts a Persian date given by year, month, day
into the equivalent Unix date.
Returns the current date either as a fixed day or a Persian date.
Returns the year
field of a Persian date.
Link to this section Types
Specs
fixed() :: integer()
Specs
persian_date() :: {persian_year(), persian_month(), persian_day()}
Specs
persian_day() :: 1..31
Specs
persian_month() :: 1..12
Specs
persian_year() :: :non_zero_integer
Specs
t() :: persian_date()
Link to this section Functions
Specs
aban(:integer | :name) :: integer()
Returns the month aban
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.aban()
8
iex>Elixir.Persian.aban(:integer)
8
iex>Elixir.Persian.aban(:name)
"Aban"
Specs
add_days(fixed() | persian_date(), integer(), :fixed | :date) :: fixed() | persian_date()
Adds the number of days
to a fixed day or Persian 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 Persian date.
Examples
iex>Elixir.Persian.add_days(730739, 100)
730839
iex>Elixir.Persian.add_days(730739, -100)
730639
iex>Elixir.Persian.add_days(730739, 100, :fixed)
730839
iex>Elixir.Persian.add_days(730739, -100, :fixed)
730639
iex>Elixir.Persian.add_days(730739, 100, :date)
{1380, 9, 29}
iex>Elixir.Persian.add_days(730739, -100, :date)
{1380, 3, 13}
iex>Elixir.Persian.add_days({1380, 6, 20}, 100)
730839
iex>Elixir.Persian.add_days({1380, 6, 20}, -100)
730639
iex>Elixir.Persian.add_days({1380, 6, 20}, 100, :fixed)
730839
iex>Elixir.Persian.add_days({1380, 6, 20}, -100, :fixed)
730639
iex>Elixir.Persian.add_days({1380, 6, 20}, 100, :date)
{1380, 9, 29}
iex>Elixir.Persian.add_days({1380, 6, 20}, -100, :date)
{1380, 3, 13}
Specs
as_date(fixed() | persian_date()) :: persian_date()
Returns a fixed day or Persian date as a Persian date.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Persian.as_date(730739)
{1380, 6, 20}
iex>Elixir.Persian.as_date({1380, 6, 20})
{1380, 6, 20}
Specs
as_fixed(fixed() | persian_date()) :: fixed()
Returns a fixed day or Persian date as a fixed day.
This is a convenience function to simplify certain function calls.
Examples
iex>Elixir.Persian.as_fixed(730739)
730739
iex>Elixir.Persian.as_fixed({1380, 6, 20})
730739
Specs
as_type(fixed() | persian_date(), :fixed | :date) :: fixed() | persian_date()
Returns a fixed day or Persian date either as a fixed day or a Persian date.
The type
parameter determines the type of the returned value:
:fixed
returns a fixed day (default),:date
returns a Persian date.
Examples
iex>Elixir.Persian.as_type(730739)
730739
iex>Elixir.Persian.as_type(730739, :fixed)
730739
iex>Elixir.Persian.as_type(730739, :date)
{1380, 6, 20}
iex>Elixir.Persian.as_type({1380, 6, 20})
730739
iex>Elixir.Persian.as_type({1380, 6, 20}, :fixed)
730739
iex>Elixir.Persian.as_type({1380, 6, 20}, :date)
{1380, 6, 20}
Specs
azar(:integer | :name) :: integer()
Returns the month azar
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.azar()
9
iex>Elixir.Persian.azar(:integer)
9
iex>Elixir.Persian.azar(:name)
"Azar"
Specs
bahman(:integer | :name) :: integer()
Returns the month bahman
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.bahman()
11
iex>Elixir.Persian.bahman(:integer)
11
iex>Elixir.Persian.bahman(:name)
"Bahman"
Returns a list of the Calixir functions of the Persian calendar.
The type
parameter determines the type of the returned Calixir function:
:atom
returns the internal names of the functions (default),:spec
returns the complete specifications of the functions.
Examples
iex>Elixir.Persian.calixir_api()
[:persian_epoch, :tehran, :midday_in_tehran, :persian_new_year_on_or_before, :fixed_from_persian, :persian_from_fixed, :arithmetic_persian_leap_year?, :fixed_from_arithmetic_persian, :arithmetic_persian_year_from_fixed, :arithmetic_persian_from_fixed, :nowruz]
iex>Elixir.Persian.calixir_api(:atom)
[:persian_epoch, :tehran, :midday_in_tehran, :persian_new_year_on_or_before, :fixed_from_persian, :persian_from_fixed, :arithmetic_persian_leap_year?, :fixed_from_arithmetic_persian, :arithmetic_persian_year_from_fixed, :arithmetic_persian_from_fixed, :nowruz]
iex>Elixir.Persian.calixir_api(:fun_specs)
[[:persian_epoch, []], [:tehran, []], [:midday_in_tehran, [:fixed]], [:persian_new_year_on_or_before, [:fixed]], [:fixed_from_persian, [:year, :month, :day]], [:persian_from_fixed, [:fixed]], [:arithmetic_persian_leap_year?, [:year]], [:fixed_from_arithmetic_persian, [:year, :month, :day]], [:arithmetic_persian_year_from_fixed, [:fixed]], [:arithmetic_persian_from_fixed, [:fixed]], [:nowruz, [:gregorian_year]]]
Specs
compare(persian_date(), persian_date()) :: :lt | :eq | :gt
Compares two Persian dates and returns...
:lt
ifdate1
is smaller (= earlier) thandate2
,:eq
ifdate1
is equaldate2
,:gt
ifdate1
is larger (= later) thandate2
.
Examples
iex>Elixir.Persian.compare({1380, 6, 20}, {1380, 6, 20})
:eq
iex>Elixir.Persian.compare({1380, 6, 20}, {1380, 9, 29})
:lt
iex>Elixir.Persian.compare({1380, 9, 29}, {1380, 6, 20})
:gt
Specs
date(persian_year(), persian_month(), persian_day()) :: t()
Returns a Persian date from its fields year, month, day
.
Example
iex>Elixir.Persian.date(1380, 6, 20)
{1380, 6, 20}
Specs
date_diff(fixed() | persian_date(), fixed() | persian_date()) :: integer()
Returns the difference (= number of days) between two Persian dates.
The dates can be given as fixed days or Persian 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.Persian.date_diff(730739, 730839)
100
iex>Elixir.Persian.date_diff(730839, 730739)
-100
iex>Elixir.Persian.date_diff({1380, 6, 20}, {1380, 9, 29})
100
iex>Elixir.Persian.date_diff({1380, 9, 29}, {1380, 6, 20})
-100
iex>Elixir.Persian.date_diff(730739, {1380, 9, 29})
100
iex>Elixir.Persian.date_diff({1380, 6, 20}, 730839)
100
Specs
day(fixed() | persian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the day
field of a Persian 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.Persian.day(730739)
20
iex>Elixir.Persian.day(730739, :atom)
:day
iex>Elixir.Persian.day(730739, :index)
2
iex>Elixir.Persian.day(730739, :name)
"Day"
iex>Elixir.Persian.day(730739, :value)
20
iex>Elixir.Persian.day({1380, 6, 20})
20
iex>Elixir.Persian.day({1380, 6, 20}, :atom)
:day
iex>Elixir.Persian.day({1380, 6, 20}, :index)
2
iex>Elixir.Persian.day({1380, 6, 20}, :name)
"Day"
iex>Elixir.Persian.day({1380, 6, 20}, :value)
20
Specs
dey(:integer | :name) :: integer()
Returns the month dey
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.dey()
10
iex>Elixir.Persian.dey(:integer)
10
iex>Elixir.Persian.dey(:name)
"Dey"
Specs
epoch() :: number()
Returns the epoch of the Persian calendar.
Example
iex>Elixir.Persian.epoch()
226896
Specs
eq(persian_date(), persian_date()) :: boolean()
Returns true if Persian date1
is equal Persian date2
, otherwise false.
Examples
iex>Elixir.Persian.eq({1380, 6, 20}, {1380, 6, 20})
true
iex>Elixir.Persian.eq({1380, 6, 20}, {1380, 9, 29})
false
iex>Elixir.Persian.eq({1380, 9, 29}, {1380, 6, 20})
false
Specs
esfand(:integer | :name) :: integer()
Returns the month esfand
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.esfand()
12
iex>Elixir.Persian.esfand(:integer)
12
iex>Elixir.Persian.esfand(:name)
"Esfand"
Specs
farvardin(:integer | :name) :: integer()
Returns the month farvardin
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.farvardin()
1
iex>Elixir.Persian.farvardin(:integer)
1
iex>Elixir.Persian.farvardin(:name)
"Farvardin"
Specs
Returns the name of the field atom in a Persian date at field_index
.
Examples
iex>Elixir.Persian.field_atom(0)
:year
iex>Elixir.Persian.field_atom(1)
:month
iex>Elixir.Persian.field_atom(2)
:day
Specs
field_atoms() :: [atom()]
Returns a list of the field atoms (names) of a Persian date.
Example
iex>Elixir.Persian.field_atoms()
[:year, :month, :day]
Specs
field_count() :: integer()
Returns the number of fields in a Persian date
Example
iex>Elixir.Persian.field_count()
3
Specs
Returns the index (= position) of the field_atom
in a Persian date.
Examples
iex>Elixir.Persian.field_index(:year)
0
iex>Elixir.Persian.field_index(:month)
1
iex>Elixir.Persian.field_index(:day)
2
Specs
Converts the other_date
of the other_calendar
into the equivalent date of the Persian calendar.
Example
iex>Elixir.Persian.from_date({2001, 9, 11}, Gregorian)
{1380, 6, 20}
Specs
from_fixed(fixed()) :: persian_date()
Converts a fixed day to a Persian
date.
Example
iex>Elixir.Persian.from_fixed(730739)
{1380, 6, 20}
Specs
from_jd(tuple() | number()) :: persian_date()
Converts a Julian Day into the equivalent Persian date.
The Julian Day can be given as a tuple or by a Julian day
.
Examples
iex>Elixir.Persian.from_jd({2452163.5})
{1380, 6, 20}
iex>Elixir.Persian.from_jd(2452163.5)
{1380, 6, 20}
Specs
from_rata_die(tuple() | integer()) :: persian_date()
Converts a RataDie date into the equivalent Persian date.
The RataDie date can be given as a tuple or by a RataDie rd
.
Examples
iex>Elixir.Persian.from_rata_die({730739})
{1380, 6, 20}
iex>Elixir.Persian.from_rata_die(730739)
{1380, 6, 20}
Specs
from_unix(tuple() | integer()) :: persian_date()
Converts a Unix date into the equivalent Persian date.
The Unix date can be given as a tuple or by Unix seconds
.
Examples
iex>Elixir.Persian.from_unix({1000166400})
{1380, 6, 20}
iex>Elixir.Persian.from_unix(1000166400)
{1380, 6, 20}
Specs
ge(persian_date(), persian_date()) :: boolean()
Returns true if Persian date1
is greater (= later) than or equal Persian date2
, otherwise false.
Examples
iex>Elixir.Persian.ge({1380, 6, 20}, {1380, 6, 20})
true
iex>Elixir.Persian.ge({1380, 6, 20}, {1380, 9, 29})
false
iex>Elixir.Persian.ge({1380, 9, 29}, {1380, 6, 20})
true
Specs
gt(persian_date(), persian_date()) :: boolean()
Returns true if Persian date1
is greater (= later) than Persian date2
, otherwise false.
Examples
iex>Elixir.Persian.gt({1380, 6, 20}, {1380, 6, 20})
false
iex>Elixir.Persian.gt({1380, 6, 20}, {1380, 9, 29})
false
iex>Elixir.Persian.gt({1380, 9, 29}, {1380, 6, 20})
true
Returns a list of the holidays of the Persian 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.Persian.holidays()
["Nowruz"]
iex>Elixir.Persian.holidays(:atom)
[:nowruz]
iex>Elixir.Persian.holidays(:name)
["Nowruz"]
Specs
keyword() :: atom()
Returns the internal keyword of the Persian calendar.
Example
iex>Elixir.Persian.keyword()
:persian
Specs
khordad(:integer | :name) :: integer()
Returns the month khordad
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.khordad()
3
iex>Elixir.Persian.khordad(:integer)
3
iex>Elixir.Persian.khordad(:name)
"Khordad"
Specs
le(persian_date(), persian_date()) :: boolean()
Returns true if Persian date1
is smaller (= earlier) than or equal Persian date2
, otherwise false.
Examples
iex>Elixir.Persian.le({1380, 6, 20}, {1380, 6, 20})
true
iex>Elixir.Persian.le({1380, 6, 20}, {1380, 9, 29})
true
iex>Elixir.Persian.le({1380, 9, 29}, {1380, 6, 20})
false
Specs
lt(persian_date(), persian_date()) :: boolean()
Returns true if Persian date1
is smaller (= earlier) than Persian date2
, otherwise false.
Examples
iex>Elixir.Persian.lt({1380, 6, 20}, {1380, 6, 20})
false
iex>Elixir.Persian.lt({1380, 6, 20}, {1380, 9, 29})
true
iex>Elixir.Persian.lt({1380, 9, 29}, {1380, 6, 20})
false
Specs
mehr(:integer | :name) :: integer()
Returns the month mehr
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.mehr()
7
iex>Elixir.Persian.mehr(:integer)
7
iex>Elixir.Persian.mehr(:name)
"Mehr"
Specs
module() :: module()
Returns the module of the Persian calendar.
Example
iex>Elixir.Persian.module()
Persian
Specs
month(fixed() | persian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the month
field of a Persian 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.Persian.month(730739)
6
iex>Elixir.Persian.month(730739, :atom)
:month
iex>Elixir.Persian.month(730739, :index)
1
iex>Elixir.Persian.month(730739, :name)
"Month"
iex>Elixir.Persian.month(730739, :value)
6
iex>Elixir.Persian.month({1380, 6, 20})
6
iex>Elixir.Persian.month({1380, 6, 20}, :atom)
:month
iex>Elixir.Persian.month({1380, 6, 20}, :index)
1
iex>Elixir.Persian.month({1380, 6, 20}, :name)
"Month"
iex>Elixir.Persian.month({1380, 6, 20}, :value)
6
Specs
Returns a list of the months of the Persian calendar.
The type
parameter determines the type of the returned months:
:integer
returns the numbers of the months,:atom
returns the internal names of the months,:name
returns the common names of the months (default).
Examples
iex>Elixir.Persian.months()
["Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"]
iex>Elixir.Persian.months(:integer)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
iex>Elixir.Persian.months(:atom)
[:farvardin, :ordibehesht, :khordad, :tir, :mordad, :shahrivar, :mehr, :aban, :azar, :dey, :bahman, :esfand]
iex>Elixir.Persian.months(:name)
["Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"]
Specs
mordad(:integer | :name) :: integer()
Returns the month mordad
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.mordad()
5
iex>Elixir.Persian.mordad(:integer)
5
iex>Elixir.Persian.mordad(:name)
"Mordad"
Specs
name() :: atom()
Returns the internal name of the Persian calendar.
Example
iex>Elixir.Persian.name()
"Persian"
Specs
nowruz(Gregorian.gregorian_year()) :: fixed() | persian_date()
Returns the fixed date of Nowruz
of the
Persian 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 Persian date.
Example
iex>Elixir.Persian.nowruz(2001)
{2001, 3, 21}
Specs
ordibehesht(:integer | :name) :: integer()
Returns the month ordibehesht
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.ordibehesht()
2
iex>Elixir.Persian.ordibehesht(:integer)
2
iex>Elixir.Persian.ordibehesht(:name)
"Ordibehesht"
Specs
range(persian_date(), persian_date()) :: integer()
Returns the distance between two Persian dates as a range of fixed days.
Example
iex>Elixir.Persian.range({1380, 6, 20}, {1380, 9, 29})
730739..730839
Specs
shahrivar(:integer | :name) :: integer()
Returns the month shahrivar
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.shahrivar()
6
iex>Elixir.Persian.shahrivar(:integer)
6
iex>Elixir.Persian.shahrivar(:name)
"Shahrivar"
Specs
start_of_day() :: :midnight | :sunset | :sunrise | :noon
Returns the start of the day in the Persian calendar.
Possible return values are:
:midnight
,:noon
,:sunrise
,:sunset
,
Example
iex>Elixir.Persian.start_of_day()
:midnight
Specs
tir(:integer | :name) :: integer()
Returns the month tir
of the Persian
calendar.
The type
parameter determines the type of the returned month:
:integer
returns the number of the month (default),:name
returns the name of the month.
Examples
iex>Elixir.Persian.tir()
4
iex>Elixir.Persian.tir(:integer)
4
iex>Elixir.Persian.tir(:name)
"Tir"
Specs
to_date(persian_date(), module()) :: tuple()
Converts a Persian date
into the equivalent date
of the other_calendar
.
For the following example to work the Gregorian calendar must be available.
Example
iex>Elixir.Persian.to_date({1380, 6, 20}, Gregorian)
{2001, 9, 11}
Specs
to_fixed(persian_date()) :: fixed()
Converts a Persian date tuple into a fixed day.
Example
iex>Elixir.Persian.to_fixed({1380, 6, 20})
730739
Specs
to_fixed(persian_year(), persian_month(), persian_day()) :: fixed()
Converts a Persian date given by year, month, day
into a fixed day.
Example
iex>Elixir.Persian.to_fixed(1380, 6, 20)
730739
Specs
to_jd(persian_date()) :: {number()}
Converts a Persian date into the equivalent Julian Day.
Example
iex>Elixir.Persian.to_jd({1380, 6, 20})
{2452163.5}
Specs
to_jd(persian_year(), persian_month(), persian_day()) :: {number()}
Converts a Persian date given by year, month, day
into the equivalent Julian Day.
Example
iex>Elixir.Persian.to_jd(1380, 6, 20)
{2452163.5}
Specs
to_rata_die(persian_date()) :: {integer()}
Converts a Persian date into the equivalent RataDie date.
Example
iex>Elixir.Persian.to_rata_die({1380, 6, 20})
{730739}
Specs
to_rata_die(persian_year(), persian_month(), persian_day()) :: {integer()}
Converts a Persian date given by year, month, day
into the equivalent RataDie date.
Example
iex>Elixir.Persian.to_rata_die(1380, 6, 20)
{730739}
Specs
to_unix(persian_date()) :: {integer()}
Converts a Persian date into the equivalent Unix date.
Example
iex>Elixir.Persian.to_unix({1380, 6, 20})
{1000166400}
Specs
to_unix(persian_year(), persian_month(), persian_day()) :: {integer()}
Converts a Persian date given by year, month, day
into the equivalent Unix date.
Example
iex>Elixir.Persian.to_unix(1380, 6, 20)
{1000166400}
Specs
today(:fixed | :date) :: fixed() | persian_date()
Returns the current date either as a fixed day or a Persian 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 Persian date.
Examples
Elixir.Persian.today()
730739
Elixir.Persian.today(:fixed)
730739
Elixir.Persian.today(:date)
{1380, 6, 20}
Specs
year(fixed() | persian_date(), :atom | :index | :name | :value) :: :atom | integer() | String.t() | number()
Returns the year
field of a Persian 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.Persian.year(730739)
1380
iex>Elixir.Persian.year(730739, :atom)
:year
iex>Elixir.Persian.year(730739, :index)
0
iex>Elixir.Persian.year(730739, :name)
"Year"
iex>Elixir.Persian.year(730739, :value)
1380
iex>Elixir.Persian.year({1380, 6, 20})
1380
iex>Elixir.Persian.year({1380, 6, 20}, :atom)
:year
iex>Elixir.Persian.year({1380, 6, 20}, :index)
0
iex>Elixir.Persian.year({1380, 6, 20}, :name)
"Year"
iex>Elixir.Persian.year({1380, 6, 20}, :value)
1380