View Source Jalaali.Calendar (jalaali v0.4.1)
A calendar implementation based on jalaali calendar system
Link to this section Summary
Functions
Converts the given date into a string.
Converts a Date struct to string human readable format
Convers the datetime (with time zone) into a human readable string.
Calculates the day and era from the given year
, month
, and day
.
Returns day of week on a spesific set of year, month and day
Calculates the day of the year from the given year
, month
, and day
.
It is an integer from 1 to 366.
In Jalaali calendar new day starts at midnight.
This function always returns {0, 1}
as result.
Returns how many months there are in the given year.
Converts the t:Calendar.iso_days
format to the datetime format specified by this calendar.
Returns the t:Calendar.iso_days
format of the specified date.
Converts the datetime (without time zone) into a human readable string.
Calculates the quarter of the year from the given year
, month
, and day
.
It is an integer from 1 to 4.
Converts a day fraction to this Calendar's representation of time.
Returns the normalized day fraction of the specified time.
Converts the given time into a string.
Calculates the year and era from the given year
.
Link to this section Types
@type day() :: pos_integer()
@type day_fraction() :: {parts_in_day :: non_neg_integer(), parts_per_day :: pos_integer()}
@type day_of_week() :: pos_integer()
@type hour() :: integer()
@type iso_days() :: {days :: integer(), day_fraction()}
@type minute() :: integer()
@type month() :: pos_integer()
@type second() :: integer()
@type year() :: neg_integer() | integer()
Link to this section Functions
Converts the given date into a string.
Converts a Date struct to string human readable format
- Extended type of string date. e.g.: "2017-01-05"
:extended
- Basic type of string date. e.g.: "20170105"
:basic
datetime_to_string(year, month, day, hour, minute, second, microsecond, time_zone, zone_abbr, utc_offset, std_offset)
View Source@spec datetime_to_string( integer(), integer(), integer(), integer(), integer(), integer(), {any(), integer()}, binary(), any(), number(), number() ) :: String.t()
Convers the datetime (with time zone) into a human readable string.
@spec day_of_era(year(), month(), day()) :: {day :: pos_integer(), era :: 0..1}
Calculates the day and era from the given year
, month
, and day
.
examples
Examples
iex> Jalaali.Calendar.day_of_era(0, 1, 1)
{366, 0}
iex> Jalaali.Calendar.day_of_era(1, 1, 1)
{1, 1}
iex> Jalaali.Calendar.day_of_era(0, 12, 30)
{1, 0}
iex> Jalaali.Calendar.day_of_era(0, 12, 29)
{2, 0}
iex> Jalaali.Calendar.day_of_era(-1, 12, 29)
{367, 0}
@spec day_of_week(integer(), pos_integer(), pos_integer(), atom()) :: tuple() | {1 | 2 | 3 | 4 | 5 | 6 | 7, 1, 7}
Returns day of week on a spesific set of year, month and day
Calculates the day of the year from the given year
, month
, and day
.
It is an integer from 1 to 366.
examples
Examples
iex> Jalaali.Calendar.day_of_year(1398, 1, 31)
31
iex> Jalaali.Calendar.day_of_year(-61, 2, 1)
32
iex> Jalaali.Calendar.day_of_year(1397, 2, 28)
59
In Jalaali calendar new day starts at midnight.
This function always returns {0, 1}
as result.
@spec months_in_year(year()) :: 12
Returns how many months there are in the given year.
It's always 12 for Jalaali calendar system.
examples
Examples
iex> Jalaali.Calendar.months_in_year(1398)
12
@spec naive_datetime_from_iso_days(iso_days()) :: {year(), month(), day(), hour(), minute(), second(), microsecond()}
Converts the t:Calendar.iso_days
format to the datetime format specified by this calendar.
naive_datetime_to_iso_days(year, month, day, hour, minute, second, microsecond)
View Source@spec naive_datetime_to_iso_days( year(), month(), day(), hour(), minute(), second(), microsecond() ) :: iso_days()
Returns the t:Calendar.iso_days
format of the specified date.
naive_datetime_to_string(year, month, day, hour, minute, second, microsecond)
View Source@spec naive_datetime_to_string( year(), month(), day(), hour(), minute(), second(), microsecond() ) :: String.t()
Converts the datetime (without time zone) into a human readable string.
Calculates the quarter of the year from the given year
, month
, and day
.
It is an integer from 1 to 4.
examples
Examples
iex> Jalaali.Calendar.quarter_of_year(1398, 1, 31)
1
iex> Jalaali.Calendar.quarter_of_year(123, 4, 3)
2
iex> Jalaali.Calendar.quarter_of_year(-61, 9, 31)
3
iex> Jalaali.Calendar.quarter_of_year(2678, 12, 28)
4
@spec time_from_day_fraction(day_fraction()) :: {hour(), minute(), second(), microsecond()}
Converts a day fraction to this Calendar's representation of time.
examples
Examples
iex> Calendar.ISO.time_from_day_fraction({1,2})
{12, 0, 0, {0, 6}}
iex> Calendar.ISO.time_from_day_fraction({13,24})
{13, 0, 0, {0, 6}}
@spec time_to_day_fraction(number(), number(), number(), {number(), any()}) :: {number(), 86_400_000_000}
Returns the normalized day fraction of the specified time.
examples
Examples
iex> Calendar.ISO.time_to_day_fraction(0, 0, 0, {0, 6})
{0, 86400000000}
iex> Calendar.ISO.time_to_day_fraction(12, 34, 56, {123, 6})
{45296000123, 86400000000}
Converts the given time into a string.
Calculates the year and era from the given year
.
The Jalaali calendar has two eras: the current era which
starts in year 1 and is defined as era 1
. and a second
era for those years less than 1 defined as era 0
.
examples
Examples
iex> Jalaali.Calendar.year_of_era(1)
{1, 1}
iex> Jalaali.Calendar.year_of_era(1398)
{1398, 1}
iex> Jalaali.Calendar.year_of_era(0)
{1, 0}
iex> Jalaali.Calendar.year_of_era(-1)
{2, 0}