\hijriCalendar

Hijri Calendar Class is group of functions that gets the Hijri Calendar and converts it to other calendars

This class contains functions work similar to calendar functions in PHP but it is work with Hijri Calendar. The Class has two algorithms to calculate the Hijri Date

Hijri Tabular Algorithm:
This algorithm was used by past to simplify the Hijri Calendar calculation, The result of this algorithm identical to Hijri Calendar in Microsoft programs and "The Calendar of Centuries-????? ??????" book of "Saleh Alojiry ???? ???????".
Umm Al-Qura Algorithm(Recommended).
This is the official calendar of Saudi Arabia Kingdom based on astronomical calculation which published in the site http://www.ummulqura.org.sa, the range of this algorithm from year 1318 to 1500, the start of hijri months of this algorithm can be adjusted by using CalendarAdjustment Class see file adjuster.php in folder example as sample
to set the default setting of this class use $hijri_settings variable which is an array with this sample structure:
$hijri_settings=array(
'langcode'=>'ar',
'defaultformat'=>'_j _M _Y??',
'umalqura'=> TRUE,
'adj_data'=> array(1426 => 57250, 1429 => 57339,),
'grdate_format' => 'j M Y',
);

Summary

Methods
Properties
Constants
__construct()
jd2hijri()
JDToHijri()
GregorianToHijri()
HijriToGregorian()
JulianToHijri()
HijriToJulian()
WesternToHijri()
HijriToWestern()
HijriToJD()
days_in_month()
monthnames()
month_name()
leap_year()
checkHijriDate()
english_suffix()
$umalqura
$supported_languages
umstartyear
umendyear
umstartjd
umendjd
mjd_factor
get_umalquradata()
$umdata
$adj_data
N/A
No private methods found
No private properties found
N/A

Constants

umstartyear

umstartyear

the Um Al-Qura Calendar start year

umendyear

umendyear

the Um Al-Qura Calendar end year

umstartjd

umstartjd

the Um Al-Qura Calendar start Julian day

umendjd

umendjd

the Um Al-Qura Calendar end Julian day

mjd_factor

mjd_factor

int factor for convert julianday to modified julianday

Properties

$umalqura

$umalqura : boolean

Type

boolean — TRUE to use Um Al-Qura algorithm, FALSE to use Hijri Tabular Algorithm

$supported_languages

$supported_languages : array

Type

array — Array of supported langcodes

$umdata

$umdata : array<mixed,integer>

Type

array<mixed,integer> — The Um Al-Qura Data

$adj_data

$adj_data : array

Type

array — the Um AlQura adjustment data, keys are month indexes from umstartyear, values are modified Julian day

Methods

__construct()

__construct(array  $settings = array()) : \hijri\Calendar

Create new hijri\Calendar object according to given settings

Parameters

array $settings

Optional array contains one or more settings of the hijri calendar object these settings are:

umalqura:bool
TRUE to use Um AlQura algorithm, FALSE to use Hijri Tabular algorithm
adj_data:string|array
string: contains Um Al-Qura adjustment data that got by function get_adjdata(TRUE) of CalendarAdjustment class or array contains Um Al-Qura adjustment data that got by function get_adjdata(FALSE)
if not set, the defaults from $hijri_settings global variable will be used.

Returns

\hijri\Calendar

hijri\Calendar object with the specified settings.

jd2hijri()

jd2hijri(integer  $julianday, integer  $hy, integer  $hm, integer  $hd, integer  $hz) : void

Returns Hijri date from julianday

Parameters

integer $julianday

the julianday

integer $hy

variable to store Hijri year

integer $hm

variable to store Hijri month

integer $hd

variable to store Hijri day in month

integer $hz

variable to store Hijri day in year (starting from 0)

JDToHijri()

JDToHijri(integer  $julianday) : string

Returns Hijri Date in Format month/day/year from julianday

Parameters

integer $julianday

the julianday

Returns

string —

Hijri date in format month/day/year

GregorianToHijri()

GregorianToHijri(integer  $year, integer  $month, integer  $day) : array

Return Hijri Date from Gregorian date

Parameters

integer $year

the Gregorian year

integer $month

the Gregorian month

integer $day

the Gregorian day

Returns

array —

An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day

HijriToGregorian()

HijriToGregorian(integer  $year, integer  $month, integer  $day) : array

Return Gregorian Date from Hijri date

Parameters

integer $year

the Hijri year

integer $month

the Hijri month

integer $day

the Hijri day

Returns

array —

An array contains Gregorian Date: 'y' key for year,'m' key for month,'d' key for day

JulianToHijri()

JulianToHijri(integer  $year, integer  $month, integer  $day) : array

Returns Hijri Date from Julian date

Parameters

integer $year

the Julian year

integer $month

the Julian month

integer $day

the Julian day

Returns

array —

An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day

HijriToJulian()

HijriToJulian(integer  $year, integer  $month, integer  $day) : array

Returns Julian Date from Hijri date

Parameters

integer $year

the Hijri year

integer $month

the Hijri month

integer $day

the Hijri day

Returns

array —

An array contains Julian Date: 'y' key for year,'m' key for month,'d' key for day

WesternToHijri()

WesternToHijri(integer  $year, integer  $month, integer  $day) : array

Returns Hijri Date from Western date

The Western date is Julian date before 1582 and Gregorian after

Parameters

integer $year

the Western year

integer $month

the Western month

integer $day

the Western day

Returns

array —

An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day

HijriToWestern()

HijriToWestern(integer  $year, integer  $month, integer  $day) : array

Return Western Date from Hijri date

The Western date is Julian date before 1582 and Gregorian after

Parameters

integer $year

the Hijri year

integer $month

the Hijri month

integer $day

the Hijri day

Returns

array —

An array contains Western Date: 'y' key for year,'m' key for month,'d' key for day

HijriToJD()

HijriToJD(integer  $month, integer  $day, integer  $year) : integer

Returns julianday from Hijri date

Parameters

integer $month

the Hijri month

integer $day

the Hijri day

integer $year

the Hijri year

Returns

integer —

julianday

days_in_month()

days_in_month(integer  $month, integer  $year, boolean  $umalqura = null) : integer

Returns count of days in month (29 or 30)

Parameters

integer $month

the Hijri month

integer $year

the Hijri year

boolean $umalqura

TRUE to use Um Al-Qura, FALSE to use Tabular, defaults from Calendar object

Returns

integer —

count of days in month 29 or 30

monthnames()

monthnames(string  $langcode = 'ar') : array

Returns array of the hijri month names in 20 languages

Parameters

string $langcode

the language code

Returns

array —

Array of Hijri month names, keys are month number (start from 1), values are string of month name

month_name()

month_name(string  $month, string  $langcode = 'ar', boolean  $short = FALSE) : string

Returns the hijri month name in 20 languages

Parameters

string $month

the month number

string $langcode

the language ISO code

boolean $short

return short names of months for European languages

Returns

string —

Hijri month name

leap_year()

leap_year(integer  $year, boolean  $umalqura = null) : integer

Return 1 if the given year is leap, 0 else

Parameters

integer $year

the Hijri Year

boolean $umalqura

TRUE to use Um Al-Qura, FALSE to use Tabular, defaults from Calendar object

Returns

integer —

1 if the given year is leap(have 355 days), 0 else

checkHijriDate()

checkHijriDate(integer  $year, integer  $month, integer  $day) : boolean

Checks the given Hijri date, returns true is the date is correct

Parameters

integer $year

the Hijri year

integer $month

the Hijri month

integer $day

the Hijri day

Returns

boolean —

TRUE if the given date is correct, FALSE else

english_suffix()

english_suffix(integer  $number) : string

returns english suffix for number

Parameters

integer $number

Returns

string

get_umalquradata()

get_umalquradata(boolean  $with_adj = TRUE, boolean  $return_array = FALSE) : array|boolean

Loads Um Al-Qura data and apply the adjustments

Parameters

boolean $with_adj

TRUE (default) to apply adjustments, FALSE to not

boolean $return_array

True to return umdata array, False to load umdata to $umdata variable

Returns

array|boolean —

array contains Um Al-Qura data if $return_array =true, bool true else