jalaali v0.2.1 Jalaali View Source

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 and elixir Date or DateTime from Gregorian to Jalaali in elixir Date or DateTime format

Converts and elixir Date or DateTime from Gregorian to Jalaali in elixir Date or DateTime format

Link to this section Functions

Link to this function days_to_jalaali(days) View Source
days_to_jalaali(Integer.t) :: {Integer.t, Integer.t, Integer.t}

Converts days number to jalaali date

Link to this function is_leap_jalaali_year(jy) View Source
is_leap_jalaali_year(Integer.t) :: boolean

Checks if a Jalaali year is leap

Parameters

  • jy: Jalaali Year (-61 to 3177)

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

Link to this function is_valid_jalaali_date(jdate) View Source
is_valid_jalaali_date(Tuple.t) :: boolean

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.

Link to this function is_valid_jalaali_date?(arg) View Source

Checks whether a Jalaali date is valid or not.

Parameters

  • arg1: is a tuple in shape of {jalaali_year, jalaali_month, jalaali_day}

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

  • jy: Jalaali Year (-61 to 3177)
Link to this function jalaali_month_length(jy, jm) View Source
jalaali_month_length(Integer.t, Integer.t) :: Integer.t

Number of days in a given month in a Jalaali year.

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

Link to this function jalaali_to_days(jy, jm, jd) View Source
jalaali_to_days(Integer.t, Integer.t, Integer.t) :: Integer.t

Converts jalaali date to days number

Link to this function to_gregorian(ex_dt) View Source
to_gregorian(Tuple.t) :: Tuple.t
to_gregorian(Tuple.t) :: Tuple.t
to_gregorian(DateTime.t | Date.t) :: DateTime.t | Date.t

Converts and elixir Date or DateTime from Gregorian to Jalaali in elixir Date or DateTime format

Parameters

  • ex_dt: Date or DateTime to convert

Exmaples

iex> Jalaali.to_gregorian ~D[1395-09-27] ~D[2016-12-17]

Link to this function to_jalaali(ex_dt) View Source
to_jalaali(Tuple.t) :: Tuple.t
to_jalaali(Tuple.t) :: Tuple.t
to_jalaali(DateTime.t | Date.t) :: DateTime.t | Date.t

Converts and elixir Date or DateTime from Gregorian to Jalaali in elixir Date or DateTime format

Parameters

  • ex_dt: Date or DateTime to convert

Exmaples

iex> Jalaali.to_jalaali ~D[2016-12-17] ~D[1395-09-27]