CalendarAdjustment
extends Calendar
in package
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',
);
Tags
Table of Contents
- mjd_factor = 2400000
- int factor for convert julianday to modified julianday
- umendjd = 2479960
- the Um Al-Qura Calendar end Julian day
- umendyear = 1500
- the Um Al-Qura Calendar end year
- umstartjd = 2415140
- the Um Al-Qura Calendar start Julian day
- umstartyear = 1318
- the Um Al-Qura Calendar start year
- $supported_languages : array<string|int, mixed>
- $umalqura : bool
- $adj_data : array<string|int, mixed>
- $umdata : array<string|int, int>
- $umdata_clear : array<string|int, mixed>
- $grdate_format : string
- __construct() : Calendar
- Create new hijri\CalendarAdjustment object according to given settings
- add_adj() : bool
- Adds or modifies adjustment to the calendar object
- auto_del_info() : array<string|int, mixed>
- Gives information of must delete adjustments if given month adjustment deleted
- check_auto_adj() : array<string|int, mixed>
- Gives you array of adj_data must added if you adjust the given month with the given modified julian day
- check_auto_del() : array<string|int, int>
- Returns array of month adjustment must be deleted if the given month adjustment deleted
- checkHijriDate() : bool
- Checks the given Hijri date, returns true is the date is correct
- days_in_month() : int
- Returns count of days in month (29 or 30)
- del_adj() : void
- Deletes the adjustment of the specified month
- english_suffix() : string
- returns english suffix for number
- get_adjdata() : string|array<string|int, mixed>
- returns the adjustment data
- get_current_adjs() : array<string|int, mixed>
- Gives you an array of current Umm Al-Qura adjustments
- get_possible_starts() : array<string|int, mixed>
- Gets an array of possible starts of Hijri month according to Umm Al-Qura Data and current Adjustments
- GregorianToHijri() : array<string|int, mixed>
- Return Hijri Date from Gregorian date
- HijriToGregorian() : array<string|int, mixed>
- Return Gregorian Date from Hijri date
- HijriToJD() : int
- Returns julianday from Hijri date
- HijriToJulian() : array<string|int, mixed>
- Returns Julian Date from Hijri date
- HijriToWestern() : array<string|int, mixed>
- Return Western Date from Hijri date
- jd2hijri() : void
- Returns Hijri date from julianday
- JDToHijri() : string
- Returns Hijri Date in Format month/day/year from julianday
- JulianToHijri() : array<string|int, mixed>
- Returns Hijri Date from Julian date
- leap_year() : int
- Return 1 if the given year is leap, 0 else
- month_name() : string
- Returns the hijri month name in 20 languages
- monthnames() : array<string|int, mixed>
- Returns array of the hijri month names in 20 languages
- WesternToHijri() : array<string|int, mixed>
- Returns Hijri Date from Western date
- get_umalquradata() : array<string|int, mixed>|bool
- Loads Um Al-Qura data and apply the adjustments
Constants
mjd_factor
int factor for convert julianday to modified julianday
public
mixed
mjd_factor
= 2400000
umendjd
the Um Al-Qura Calendar end Julian day
public
mixed
umendjd
= 2479960
umendyear
the Um Al-Qura Calendar end year
public
mixed
umendyear
= 1500
umstartjd
the Um Al-Qura Calendar start Julian day
public
mixed
umstartjd
= 2415140
umstartyear
the Um Al-Qura Calendar start year
public
mixed
umstartyear
= 1318
Properties
$supported_languages
public
static array<string|int, mixed>
$supported_languages
= array('ar', 'en', 'fa', 'ur', 'sq', 'az', 'bn', 'bs', 'zh', 'fr', 'de', 'hi', 'id', 'ckb', 'ms', 'ru', 'es', 'tr', 'pt', 'it')
Array of supported langcodes
Tags
$umalqura
public
bool
$umalqura
= TRUE
TRUE to use Um Al-Qura algorithm, FALSE to use Hijri Tabular Algorithm
$adj_data
protected
array<string|int, mixed>
$adj_data
the Um AlQura adjustment data, keys are month indexes from umstartyear, values are modified Julian day
$umdata
protected
array<string|int, int>
$umdata
The Um Al-Qura Data
$umdata_clear
protected
array<string|int, mixed>
$umdata_clear
original Umm Al-Qura Data without any adjustments
$grdate_format
private
string
$grdate_format
The date format to get Gregorian dates form adjustment information
Methods
__construct()
Create new hijri\CalendarAdjustment object according to given settings
public
__construct([array<string|int, mixed> $settings = array() ]) : Calendar
Parameters
- $settings : array<string|int, mixed> = array()
-
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.Tags
Return values
Calendar —hijri\CalendarAdjustment object with the specified settings.
add_adj()
Adds or modifies adjustment to the calendar object
public add_adj(int $month, int $year, int|string $new_month_start) : bool
Parameters
- $month : int
-
the Hijri month
- $year : int
-
the year of Hijri month
- $new_month_start : int|string
-
the new start of the Hijri Month can be integer (modified julian day) or string (Gregorian date (d/m/yyyy) format)
Tags
Return values
bool —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()
auto_del_info()
Gives information of must delete adjustments if given month adjustment deleted
public auto_del_info(int $month, int $year) : array<string|int, mixed>
Parameters
- $month : int
-
the Hijri month
- $year : int
-
the Hijri Year
Tags
Return values
array<string|int, mixed> —array of must to delete month adjustments, keys are 'month','year'
check_auto_adj()
Gives you array of adj_data must added if you adjust the given month with the given modified julian day
public check_auto_adj(int $off, int $v) : array<string|int, mixed>
Parameters
- $off : int
-
The index of the month to be adjusted can be given by function month2off
- $v : int
-
(modified julian day) of the new start of the month
Tags
Return values
array<string|int, mixed> —Array of adj_data must by applied if the start of month adjusted to the given day
check_auto_del()
Returns array of month adjustment must be deleted if the given month adjustment deleted
public check_auto_del(int $off) : array<string|int, int>
Parameters
- $off : int
-
the index of the month adjustment you want to delete can be given by function month2off
Tags
Return values
array<string|int, int> —Array of index of month adjustment must be deleted
checkHijriDate()
Checks the given Hijri date, returns true is the date is correct
public checkHijriDate(int $year, int $month, int $day) : bool
Parameters
- $year : int
-
the Hijri year
- $month : int
-
the Hijri month
- $day : int
-
the Hijri day
Return values
bool —TRUE if the given date is correct, FALSE else
days_in_month()
Returns count of days in month (29 or 30)
public days_in_month(int $month, int $year[, bool $umalqura = null ]) : int
Parameters
- $month : int
-
the Hijri month
- $year : int
-
the Hijri year
- $umalqura : bool = null
-
TRUE to use Um Al-Qura, FALSE to use Tabular, defaults from Calendar object
Return values
int —count of days in month 29 or 30
del_adj()
Deletes the adjustment of the specified month
public del_adj(int $month, int $year) : void
Parameters
- $month : int
-
the Hijri month
- $year : int
-
the Hijri Year
Tags
Return values
void —english_suffix()
returns english suffix for number
public static english_suffix(int $number) : string
Parameters
- $number : int
Tags
Return values
string —get_adjdata()
returns the adjustment data
public get_adjdata([bool $txt = TRUE ]) : string|array<string|int, mixed>
Parameters
- $txt : bool = TRUE
-
true to return a json encoded array string False to return array.
Tags
Return values
string|array<string|int, mixed> —string json encoded array adjustment data if $txt is true, or array of adjustment data if $txt if false
get_current_adjs()
Gives you an array of current Umm Al-Qura adjustments
public get_current_adjs() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —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)
get_possible_starts()
Gets an array of possible starts of Hijri month according to Umm Al-Qura Data and current Adjustments
public get_possible_starts(int $month, int $year) : array<string|int, mixed>
Parameters
- $month : int
-
Hijri month
- $year : int
-
Hijri year
Tags
Return values
array<string|int, mixed> —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
GregorianToHijri()
Return Hijri Date from Gregorian date
public GregorianToHijri(int $year, int $month, int $day) : array<string|int, mixed>
Parameters
- $year : int
-
the Gregorian year
- $month : int
-
the Gregorian month
- $day : int
-
the Gregorian day
Return values
array<string|int, mixed> —An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day
HijriToGregorian()
Return Gregorian Date from Hijri date
public HijriToGregorian(int $year, int $month, int $day) : array<string|int, mixed>
Parameters
- $year : int
-
the Hijri year
- $month : int
-
the Hijri month
- $day : int
-
the Hijri day
Return values
array<string|int, mixed> —An array contains Gregorian Date: 'y' key for year,'m' key for month,'d' key for day
HijriToJD()
Returns julianday from Hijri date
public HijriToJD(int $month, int $day, int $year) : int
Parameters
- $month : int
-
the Hijri month
- $day : int
-
the Hijri day
- $year : int
-
the Hijri year
Return values
int —julianday
HijriToJulian()
Returns Julian Date from Hijri date
public HijriToJulian(int $year, int $month, int $day) : array<string|int, mixed>
Parameters
- $year : int
-
the Hijri year
- $month : int
-
the Hijri month
- $day : int
-
the Hijri day
Return values
array<string|int, mixed> —An array contains Julian Date: 'y' key for year,'m' key for month,'d' key for day
HijriToWestern()
Return Western Date from Hijri date
public HijriToWestern(int $year, int $month, int $day) : array<string|int, mixed>
The Western date is Julian date before 1582 and Gregorian after
Parameters
- $year : int
-
the Hijri year
- $month : int
-
the Hijri month
- $day : int
-
the Hijri day
Return values
array<string|int, mixed> —An array contains Western Date: 'y' key for year,'m' key for month,'d' key for day
jd2hijri()
Returns Hijri date from julianday
public jd2hijri(int $julianday, int &$hy, int &$hm, int &$hd, int &$hz) : void
Parameters
- $julianday : int
-
the julianday
- $hy : int
-
variable to store Hijri year
- $hm : int
-
variable to store Hijri month
- $hd : int
-
variable to store Hijri day in month
- $hz : int
-
variable to store Hijri day in year (starting from 0)
Return values
void —JDToHijri()
Returns Hijri Date in Format month/day/year from julianday
public JDToHijri(int $julianday) : string
Parameters
- $julianday : int
-
the julianday
Return values
string —Hijri date in format month/day/year
JulianToHijri()
Returns Hijri Date from Julian date
public JulianToHijri(int $year, int $month, int $day) : array<string|int, mixed>
Parameters
- $year : int
-
the Julian year
- $month : int
-
the Julian month
- $day : int
-
the Julian day
Return values
array<string|int, mixed> —An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day
leap_year()
Return 1 if the given year is leap, 0 else
public leap_year(int $year[, bool $umalqura = null ]) : int
Parameters
- $year : int
-
the Hijri Year
- $umalqura : bool = null
-
TRUE to use Um Al-Qura, FALSE to use Tabular, defaults from Calendar object
Return values
int —1 if the given year is leap(have 355 days), 0 else
month_name()
Returns the hijri month name in 20 languages
public month_name(string $month[, string $langcode = 'ar' ][, bool $short = FALSE ]) : string
Parameters
- $month : string
-
the month number
- $langcode : string = 'ar'
-
the language ISO code
- $short : bool = FALSE
-
return short names of months for European languages
Tags
Return values
string —Hijri month name
monthnames()
Returns array of the hijri month names in 20 languages
public monthnames([string $langcode = 'ar' ]) : array<string|int, mixed>
Parameters
- $langcode : string = 'ar'
-
the language code
Return values
array<string|int, mixed> —Array of Hijri month names, keys are month number (start from 1), values are string of month name
WesternToHijri()
Returns Hijri Date from Western date
public WesternToHijri(int $year, int $month, int $day) : array<string|int, mixed>
The Western date is Julian date before 1582 and Gregorian after
Parameters
- $year : int
-
the Western year
- $month : int
-
the Western month
- $day : int
-
the Western day
Return values
array<string|int, mixed> —An array contains Hijri Date: 'y' key for year,'m' key for month,'d' key for day
get_umalquradata()
Loads Um Al-Qura data and apply the adjustments
protected get_umalquradata([bool $with_adj = TRUE ][, bool $return_array = FALSE ]) : array<string|int, mixed>|bool
Parameters
- $with_adj : bool = TRUE
-
TRUE (default) to apply adjustments, FALSE to not
- $return_array : bool = FALSE
-
True to return umdata array, False to load umdata to $umdata variable
Return values
array<string|int, mixed>|bool —array contains Um Al-Qura data if $return_array =true, bool true else
Search results