\hijriCalendarAdjustment

Hijri CalendarAdjustment Class is group of functions that help to get and correct adjustments to Umm Al-Qura Calendar

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()
get_adjdata()
check_auto_del()
check_auto_adj()
get_possible_starts()
get_current_adjs()
add_adj()
del_adj()
auto_del_info()
$umalqura
$supported_languages
umstartyear
umendyear
umstartjd
umendjd
mjd_factor
get_umalquradata()
$umdata
$adj_data
$umdata_clear
N/A
No private methods found
$grdate_format
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

$umdata_clear

$umdata_clear : array

Type

array — original Umm Al-Qura Data without any adjustments

$grdate_format

$grdate_format : string

Type

string — The date format to get Gregorian dates form adjustment information

Methods

__construct()

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

Create new hijri\CalendarAdjustment object according to given settings

Parameters

array $settings

Array contains one or more settings of the hijri CalendarAdjustment object these settings are:

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)
grdate_format: string
date format to show the Gregorian dates in adjustment process
if not set, the defaults from $hijri_settings global variable will be used.

Returns

\hijri\Calendar

hijri\CalendarAdjustment 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_adjdata()

get_adjdata(boolean  $txt = TRUE) : string|array

returns the adjustment data

Parameters

boolean $txt

true to return a json encoded array string False to return array.

Returns

string|array —

string json encoded array adjustment data if $txt is true, or array of adjustment data if $txt if false

check_auto_del()

check_auto_del(integer  $off) : array<mixed,integer>

Returns array of month adjustment must be deleted if the given month adjustment deleted

Parameters

integer $off

the index of the month adjustment you want to delete can be given by function month2off

Returns

array<mixed,integer> —

Array of index of month adjustment must be deleted

check_auto_adj()

check_auto_adj(integer  $off, integer  $v) : array

Gives you array of adj_data must added if you adjust the given month with the given modified julian day

Parameters

integer $off

The index of the month to be adjusted can be given by function month2off

integer $v

(modified julian day) of the new start of the month

Returns

array —

Array of adj_data must by applied if the start of month adjusted to the given day

get_possible_starts()

get_possible_starts(integer  $month, integer  $year) : array

Gets an array of possible starts of Hijri month according to Umm Al-Qura Data and current Adjustments

Parameters

integer $month

Hijri month

integer $year

Hijri year

Returns

array —

An array contains two numeric indexed variables (arrays) with these keys:

grdate: string
gregorion date (format d/m/yyyy) of the possible start of the hijri month
jd: int
modifed julian day of the possible start of the hijri month
currentset: bool
determine whether this date is the default start of the Hijri month
alsoadjdata: array
array contians another adjustments must be applied if the hijri month starts by this date with these keys:
month:int
The Hijri month which will be adjusted
year: int
The year of the hijri month which will be adjusted
grdate: string
The new start that Hijri month must be started in gregorion date (format d/m/yyyy)
jd: int
The modified julian day of the new start that Hijri month must be started
if the given month is out of umalqura range the function will return empty array

get_current_adjs()

get_current_adjs() : array

Gives you an array of current Umm Al-Qura adjustments

Returns

array —

An array contains (arrays) of current adjustments with these keys:

month: int
The hijri month
year: int
The hijri year of the month
current: string
Current start of the Hijri month in Gregorian date, the format will be same of grdate_format option or (d/m/yyyy)
default: string
The original start the Hijri month in Gregorian, the format will be same of grdate_format option or (d/m/yyyy)

add_adj()

add_adj(integer  $month, integer  $year, integer|string  $new_month_start) : boolean

Adds or modifies adjustment to the calendar object

Parameters

integer $month

the Hijri month

integer $year

the year of Hijri month

integer|string $new_month_start

the new start of the Hijri Month can be integer (modified julian day) or string (Gregorian date (d/m/yyyy) format)

Returns

boolean —

TRUE if the succeeded or FALSE if not

    this will add the adjustment only to the current object if you want to save it you must use get_adj_txt()

del_adj()

del_adj(integer  $month, integer  $year) : void

Deletes the adjustment of the specified month

Parameters

integer $month

the Hijri month

integer $year

the Hijri Year

auto_del_info()

auto_del_info(integer  $month, integer  $year) : array

Gives information of must delete adjustments if given month adjustment deleted

Parameters

integer $month

the Hijri month

integer $year

the Hijri Year

Returns

array —

array of must to delete month adjustments, keys are 'month','year'

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