View Source Jalaali (jalaali v0.4.1)
Jalaali module helps converting gregorian dates to jalaali dates. Jalaali calendar is widely used in Persia and Afganistan.
This module helps you with converting erlang and/or elixir DateTime formats to Jalaali date (and vice versa) and checking for leap years
Link to this section Summary
Functions
Converts days number to jalaali date
Checks if a Jalaali year is leap
This function is same as is_valid_jalaali_date?
and is only here
because i forgot to add question mark in jalaali <= 0.1.1
Checks whether a Jalaali date is valid or not.
This function determines if the Jalaali (persian) year is leap(366-day long) or is the common year (365-days), and finds the day in March (Gregorian calendar) of the first day of the Jalaali year (jy).
Number of days in a given month in a Jalaali year.
Converts jalaali date to days number
Converts erlang or elixir date or dateTime from Jalaali to Gregorian format
Converts erlang or elixir date or dateTime from Gregorian to Jalaali format
Link to this section Functions
Converts days number to jalaali date
Checks if a Jalaali year is leap
parameters
Parameters
- jy: Jalaali Year (-61 to 3177)
examples
Examples
iex> Jalaali.is_leap_jalaali_year(1395)
true
iex> Jalaali.is_leap_jalaali_year(1396)
false
iex> Jalaali.is_leap_jalaali_year(1394)
false
This function is same as is_valid_jalaali_date?
and is only here
because i forgot to add question mark in jalaali <= 0.1.1
Please use is_valid_jalaali_date?
instead.
Checks whether a Jalaali date is valid or not.
parameters
Parameters
- arg1: is a tuple in shape of {jalaali_year, jalaali_month, jalaali_day}
examples
Examples
iex> Jalaali.is_valid_jalaali_date {1395, 9, 27}
true
iex> Jalaali.is_valid_jalaali_date {1395, 91, 27}
false
This function determines if the Jalaali (persian) year is leap(366-day long) or is the common year (365-days), and finds the day in March (Gregorian calendar) of the first day of the Jalaali year (jy).
parameters
Parameters
- jy: Jalaali Year (-61 to 3177)
Number of days in a given month in a Jalaali year.
examples
Examples
iex> Jalaali.jalaali_month_length(1395, 11)
30
iex> Jalaali.jalaali_month_length(1395, 6)
31
iex> Jalaali.jalaali_month_length(1394, 12)
29
iex> Jalaali.jalaali_month_length(1395, 12)
30
Converts jalaali date to days number
@spec to_gregorian(tuple() | DateTime.t() | Date.t()) :: tuple() | DateTime.t() | Date.t()
Converts erlang or elixir date or dateTime from Jalaali to Gregorian format
parameters
Parameters
- arg1: Date to convert in erlang format (a tuple with three elements)
- arg1: Date to convert in erlang format (a tuple with three elements)
- ex_dt: Date or DateTime to convert
exmaples
Exmaples
iex> Jalaali.to_gregorian {1395, 9, 27}
{2016, 12, 17}
iex> Jalaali.to_jalaali {{2016, 12, 17}, {11, 11, 11}}
{{1395, 9, 27}, {11, 11, 11}}
iex> Jalaali.to_gregorian ~D[1395-09-27]
~D[2016-12-17]
@spec to_jalaali(tuple() | DateTime.t() | Date.t()) :: tuple() | DateTime.t() | Date.t()
Converts erlang or elixir date or dateTime from Gregorian to Jalaali format
parameters
Parameters
- arg1: Date to convert in erlang format (a tuple with three elements)
- arg1: erlang dateTime to convert in erlang format (a tuple with two difftent tuples each with 3 elements)
- ex_dt: Date or DateTime to convert
exmaples
Exmaples
iex> Jalaali.to_jalaali {2016, 12, 17}
{1395, 9, 27}
iex> Jalaali.to_jalaali {{2016, 12, 17}, {11, 11, 11}}
{{1395, 9, 27}, {11, 11, 11}}
iex> Jalaali.to_jalaali ~D[2016-12-17]
~D[1395-09-27]