/** * Converts a Gregorian date to Julian Day Count. * * Shim implementation of GregorianToJD() * * @link https://php.net/GregorianToJD * * @param integer $month * @param integer $day * @param integer $year * * @return integer */ public static function gregorianToJd($month, $day, $year) { if ($year == 0) { return 0; } else { return self::$gregorian_calendar->ymdToJd($year, $month, $day); } }
/** * Generate an estimate for the date of birth, based on dates of parents/children/spouses * * @return Date */ public function getEstimatedBirthDate() { if (is_null($this->_getEstimatedBirthDate)) { foreach ($this->getAllBirthDates() as $date) { if ($date->isOK()) { $this->_getEstimatedBirthDate = $date; break; } } if (is_null($this->_getEstimatedBirthDate)) { $min = array(); $max = array(); $tmp = $this->getDeathDate(); if ($tmp->isOK()) { $min[] = $tmp->minimumJulianDay() - $this->tree->getPreference('MAX_ALIVE_AGE') * 365; $max[] = $tmp->maximumJulianDay(); } foreach ($this->getChildFamilies() as $family) { $tmp = $family->getMarriageDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() - 365 * 1; $max[] = $tmp->minimumJulianDay() + 365 * 30; } if ($parent = $family->getHusband()) { $tmp = $parent->getBirthDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() + 365 * 15; $max[] = $tmp->minimumJulianDay() + 365 * 65; } } if ($parent = $family->getWife()) { $tmp = $parent->getBirthDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() + 365 * 15; $max[] = $tmp->minimumJulianDay() + 365 * 45; } } foreach ($family->getChildren() as $child) { $tmp = $child->getBirthDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() - 365 * 30; $max[] = $tmp->minimumJulianDay() + 365 * 30; } } } foreach ($this->getSpouseFamilies() as $family) { $tmp = $family->getMarriageDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() - 365 * 45; $max[] = $tmp->minimumJulianDay() - 365 * 15; } $spouse = $family->getSpouse($this); if ($spouse) { $tmp = $spouse->getBirthDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() - 365 * 25; $max[] = $tmp->minimumJulianDay() + 365 * 25; } } foreach ($family->getChildren() as $child) { $tmp = $child->getBirthDate(); if ($tmp->isOK()) { $min[] = $tmp->maximumJulianDay() - 365 * ($this->getSex() == 'F' ? 45 : 65); $max[] = $tmp->minimumJulianDay() - 365 * 15; } } } if ($min && $max) { $gregorian_calendar = new GregorianCalendar(); list($year) = $gregorian_calendar->jdToYmd((int) ((max($min) + min($max)) / 2)); $this->_getEstimatedBirthDate = new Date('EST ' . $year); } else { $this->_getEstimatedBirthDate = new Date(''); // always return a date object } } } return $this->_getEstimatedBirthDate; }
/** * Calculate the gregorian year for a date. This should NOT be used internally * within WT - we should keep the code "calendar neutral" to allow support for * jewish/arabic users. This is only for interfacing with external entities, * such as the ancestry.com search interface or the dated fact icons. * * @return int */ public function gregorianYear() { if ($this->isOK()) { $gregorian_calendar = new GregorianCalendar(); list($year) = $gregorian_calendar->jdToYmd($this->julianDay()); return $year; } else { return 0; } }
<?php /** * User: Hossein Moradgholi * Date: 10/25/15 * Time: 12:01 AM */ error_reporting(E_ERROR); use Fisharebest\ExtCalendar\GregorianCalendar; use Fisharebest\ExtCalendar\PersianCalendar; use Nikapps\BatchPayment\Paya\PayaCollection; use Nikapps\BatchPayment\Paya\PayaPayment; use Nikapps\BatchPayment\Paya\PayaPaymentInfo; require "../vendor/autoload.php"; $payaCollection = new PayaCollection(); $payaPaymentInfo = new PayaPaymentInfo(); $persianCalendar = new PersianCalendar(); $gregorianCalendar = new GregorianCalendar(); $requestDateTime = implode('-', $persianCalendar->jdToYmd($gregorianCalendar->ymdToJd(date('Y'), date('m'), date('d')))) . "T" . date('H:i:s'); $payaPaymentInfo->setRequestDate($requestDateTime); $payaPaymentInfo->setPayerIban('IR360560080133100002001001940612002'); $payaPaymentInfo->setPayerName('نام من'); $payaPayment = new PayaPayment(); $payaPayment->setAmount(2080000); $payaPayment->setCreditorIban('IR020540110180001974695003'); $payaPayment->setCreditorName('امیرحسین صادقی'); $payaPayment->setDescription('تست سیستم'); $payaPaymentInfo->addPayment($payaPayment); $payaCollection->setPayaPaymentInfo($payaPaymentInfo); $payaCollection->exportXml();
private static function search_indis_year_range($startyear, $endyear) { // At present, the lifespan chart is driven by Gregorian years. // We ought to allow it to work with other calendars... $gregorian_calendar = new GregorianCalendar(); $startjd = $gregorian_calendar->ymdToJd($startyear, 1, 1); $endjd = $gregorian_calendar->ymdToJd($endyear, 12, 31); $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . " FROM `##individuals`" . " JOIN `##dates` ON i_id=d_gid AND i_file=d_file" . " WHERE i_file=? AND d_julianday1 BETWEEN ? AND ?"; $rows = WT_DB::prepare($sql)->execute(array(WT_GED_ID, $startjd, $endjd))->fetchAll(); $list = array(); foreach ($rows as $row) { $list[] = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } return $list; }