/** * {@inheritdoc} */ public function toJulianDay(DateInterface $date) { if (!$date instanceof NativeDate) { throw new \InvalidArgumentException("The date must be NativeDate"); } return unixtojd($date->getTimeStamp()); }
/** * Creates an instance of user. * * @param string $email The email * @param string $username The username * @param string $firstName The firstName * @param string $lastName The lastName * @param boolean $enabled Boolean that checks if the user is enabled or not, by default is false * * @return \Kreta\Component\User\Model\Interfaces\UserInterface */ public function create($email, $username, $firstName, $lastName, $enabled = false) { $user = new $this->className(); if (false === $enabled) { $user->setConfirmationToken(sprintf('%s%s', uniqid('kreta'), unixtojd())); } return $user->setUsername($username)->setFirstName($firstName)->setLastName($lastName)->setEmail($email)->setEnabled($enabled); }
/** * True if the event is in the past. * In practice, we check if the event's end date (if any) or start date is on a day before today. * @param Event $evt * @return bool */ public function eventInPast(Event $event) { if (isset($evt->endDate)) { $evtDate = $event->endDate; } else { $evtDate = $event->start; } return unixtojd($evtDate) < unixtojd(time()); }
function karma_calculate($statuses) { $return = new stdClass(); $daily_karma = array(); //$daily_status_count = array(); $comment_count = 0; $like_count = 0; $denominator = 0.; foreach ($statuses as $status) { // get the timestamp of the date $daystamp = unixtojd(strtotime(substr($status['updated_time'], 0, 11))); $karma = karma($status); array_accum($daily_karma, $daystamp, $karma); //array_accum($daily_status_count, $daystamp, 1); $comment_count += $status['comment_count']; $like_count += $status['like_count']; // For the Wilson score, we need to find a proportion of "positive values". Therefore we set an absolute value for max karma per status message. $denominator += max($karma, 10); } //print_r($daily_status_count); //print_r(array_fill_missing_desc($daily_status_count)); //print 'sharpe: ' . sharpe_ratio($a); //print "\nsum:" . array_sum($daily_karma) . "\n"; $wilson_score = Rating::ratingAverage(array_sum($daily_karma), $denominator); $return->pop_index = $wilson_score * 100; $daily_karma_full = array_fill_missing_desc($daily_karma); $return->comment_count = $comment_count; $return->like_count = $like_count; $return->day_count = count($daily_karma); $return->status_count = count($statuses); return $return; }
function display($tpl = null) { // What type of event to we want? // TODO: Probably shouldn't return anything that isn't OK to publish - this is publicly accessible. This may be the cause of null events in the bottomless page output. $type = JRequest::getVar('eventtype', null, "get"); $id = JRequest::getVar('id', null, "get", "INTEGER"); if (isset($id) && isset($type)) { // Single event - connect directly to SWG backend // TODO: eventFactory method to take strings as well switch (strtolower($type)) { case "social": $factory = SWG::socialFactory(); break; case "walk": $factory = SWG::walkInstanceFactory(); break; case "weekend": $factory = SWG::weekendFactory(); break; } $result = $factory->getSingle($id); print $result->jsonEncode(); } else { // Go through the model $events = $this->get('Events'); $result = array(); foreach ($events as $event) { $evtProps = $event->sharedProperties(); // Remove contact details from past events. Not really the best place to do it, but oh well. At least it means end users can't see them. if (isset($event->endDate) && unixtojd($event->endDate) < unixtojd(time()) || isset($event->start) && unixtojd($event->start) < unixtojd(time())) { unset($evtProps['leader']['telephone']); } $result[] = $evtProps; } print json_encode($result); } }
/** * Update the timestamp held by this entry. * * @param int the timestamp held by this entry in the correct form * as indicated by the third argument. For {@link UNIX_TIMESTAMP} * this is an integer counting the number of seconds since January * 1st 1970, for {@link EXIF_STRING} this is a string of the form * 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a * floating point number where the integer part denotes the day * count and the fractional part denotes the time of day (0.25 means * 6:00, 0.75 means 18:00). * * @param int the type of the timestamp. This must be one of * {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or * {@link JULIAN_DAY_COUNT}. * * @todo How to deal with timezones? Use the TimeZoneOffset tag * 0x882A? */ function setValue($timestamp, $type = self::UNIX_TIMESTAMP) { switch ($type) { case self::UNIX_TIMESTAMP: $this->day_count = unixtojd($timestamp); $this->seconds = $timestamp % 86400; break; case self::EXIF_STRING: /* Clean the timestamp: some timestamps are broken other * separators than ':' and ' '. */ $d = split('[^0-9]+', $timestamp); $this->day_count = gregoriantojd($d[1], $d[2], $d[0]); $this->seconds = $d[3] * 3600 + $d[4] * 60 + $d[5]; break; case self::JULIAN_DAY_COUNT: $this->day_count = (int) floor($timestamp); $this->seconds = (int) (86400 * ($timestamp - floor($timestamp))); break; default: throw new PelInvalidArgumentException('Expected UNIX_TIMESTAMP (%d), ' . 'EXIF_STRING (%d), or ' . 'JULIAN_DAY_COUNT (%d) for $type, ' . 'got %d.', self::UNIX_TIMESTAMP, self::EXIF_STRING, self::JULIAN_DAY_COUNT, $type); } /* Now finally update the string which will be used when this is * turned into bytes. */ parent::setValue($this->getValue(self::EXIF_STRING)); }
<?php // this line has no impact on test output on Windows putenv('TZ=UTC'); // getenv('TZ') returns 'UTC' here // putenv (basic_functions.c) does call tzset() when the env var being put is 'TZ' // -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the value of 'TZ' returns 'UTC' // putting a call to date_default_timezone_set() here doesn't help // // on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section // -since putenv() is written to call tzset() when env var is TZ, I assume that putenv("TZ=UTC") is intended to work // and should work on all platforms(including Windows). // easter_date.phpt passes // -doesn't use --ENV-- section // -uses --INI-- section with date.timezone=UTC // -uses putenv('TZ=UTC') // date.timezone=UTC // -if omitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning // -easter_date() calls mktime() and localtime() // -whereas unixtojd(1000000000) calls localtime(1000000000) // -if omitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG // // unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours // -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly) // but returns -1 day from expected because its input is -1 from expected echo unixtojd(40000) . "\n"; echo unixtojd(1000000000) . "\n"; echo unixtojd(1152459009) . "\n";
break; } ++$deviceIndex; } if ($deviceIndex == count($devices)) { continue; } $days[$currentDay][$deviceIndex][$timeOfDay] = $parsedLine[8]; } } fclose($logFh); if (count($days) > 0) { ksort($days, SORT_NUMERIC); $today = strtotime('today'); $now = time() - $today; $today = unixtojd($today); $deviceStatus = array(); // keyed by deviceIndex, valued by start time foreach ($days as $day => $deviceEvents) { preg_match("!(\\d+)/(\\d+)/(\\d+)!", jdtogregorian($day), $matched); print "<tr>\n"; printf(" <td>%04d-%02d-%02d</td>\n", $matched[3], $matched[1], $matched[2]); print " <td colspan=\"24\"><div class=\"bar\">\n"; foreach ($deviceEvents as $deviceIndex => $events) { foreach ($events as $timeOfDay => $event) { if ($event == 1) { if (!isset($deviceStatus[$deviceIndex])) { $deviceStatus[$deviceIndex] = $timeOfDay; } // else switched on again -- ignore } else {
<?php //返回某一个历法中 某年 某月的总天数 CAL_GREGORIAN,CAL_JULIAN,CAL_JEWISH 和CAL_FRENCH。 $num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31 echo "There was {$num} days in August 2003"; echo "<br/>"; echo "<pre>"; //cal_from_jd ( int $jd , int $calendar ) $today = unixtojd(mktime(0, 0, 0, 8, 16, 2003)); print_r(cal_from_jd($today, CAL_GREGORIAN)); echo "<br/>"; echo "<pre>"; $info = cal_info(0); print_r($info); //指定年份的复活节 午夜时分的时间戳 echo "<br/>"; echo date("M-d-Y", easter_date(1999)); echo "<br/>"; echo easter_days(2016); echo "<br/>"; $date = new DateTime('2000-01-01'); $date->add(new DateInterval('P10D')); echo $date->format('Y-m-d') . "\n"; //2000-01-11 echo "<br/>"; $date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009'); echo $date->format('Y-m-d'); echo "<br/>"; $date = new DateTime('2016-12-12'); $date->modify('+1 day');
/** * Calculate the "corpus christi" i.e. 60 days after easter sunday * * The year must be within the unix epoche (Gregorian years between 1970 and 2037 or 2440588 <= jday <= 2465342) * @param integer $year Year for which to calculate the holiday * @param integer &$day Day of the holiday within the given year * @param integer &$month Month of the holiday within the given year * @access private * @static */ function corpusChristi($year, &$day, &$month) { $easter_timestamp = jdtounix(unixtojd(easter_date($year)) + 60); $day = date("d", $easter_timestamp); $month = date("m", $easter_timestamp); }
/** * Return language specific formatted date * * @access public * @param $fmt (see date() in php.net) * @param $timestamp * @return string */ function date_lang($fmt, $timestamp = 0) { $jd = unixtojd($timestamp); $pdate = jd_to_persian($jd); $date_lang = date($fmt, $timestamp); if (strpos($fmt, 'a') !== false) { $a = date('a', $timestamp); // e.g. am or pm $date_lang = str_replace($a, lang($a), $date_lang); } if (strpos($fmt, 'A') !== false) { $a = date('A', $timestamp); // e.g. AM or PM $date_lang = str_replace($a, lang($a), $date_lang); } if (strpos($fmt, 'l') !== false) { $l = date('l', $timestamp); // e.g. Thursday $n = date('N', $timestamp); // e.g. 1=Monday, ..., 7=Sunday $date_lang = str_replace($l, lang('weekday full ' . $n), $date_lang); } if (strpos($fmt, 'D') !== false) { $d = date('D', $timestamp); // e.g. Thu $n = date('N', $timestamp); // e.g. 1=Monday, ..., 7=Sunday $date_lang = str_replace($d, lang('weekday short ' . $n), $date_lang); } if (strpos($fmt, 'M') !== false) { $m = date('M', $timestamp); // e.g. Feb $n = date('n', $timestamp); // e.g. 2 $date_lang = str_replace($m, lang('month short ' . $n), $date_lang); } if (strpos($fmt, 'F') !== false) { $f = date('F', $timestamp); // e.g. February $n = date('n', $timestamp); // e.g. 2 $date_lang = str_replace($f, lang('month full ' . $n), $date_lang); } if (strpos($fmt, 'S') !== false) { $s = date('S', $timestamp); // e.g. st, nd, rd or th $n = 4; if ($s == 'st') { $n = 1; } if ($s == 'nd') { $n = 2; } if ($s == 'rd') { $n = 3; } $date_lang = str_replace($s, lang('ordinal ' . $n), $date_lang); } //return $date_lang . ' reversed Persian=' . utf8_strrev(FormatPersianSmallDate ( $pdate )) . ' Persian=' . FormatPersianSmallDate ( $pdate ); //return utf8_strrev(FormatPersianDate ( $pdate )); return $date_lang; }
<?php $jday = unixtojd(); echo jdtojewish($jday);
/** * Fonction retournant le nombre de jour feries, samedis et dimanches entre 2 dates entrees en timestamp. Dates must be UTC with hour, day, min to 0 * Called by function num_open_day * * @param int $timestampStart Timestamp de debut * @param int $timestampEnd Timestamp de fin * @param string $countrycode Country code * @return int Nombre de jours feries */ function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR') { $nbFerie = 0; // Check to ensure we use correct parameters if (($timestampEnd - $timestampStart) % 86400 != 0) { return 'ErrorDates must use same hours and must be GMT dates'; } $i = 0; while ($timestampStart < $timestampEnd && $i < 50000) { $ferie = false; $countryfound = 0; $jour = date("d", $timestampStart); $mois = date("m", $timestampStart); $annee = date("Y", $timestampStart); if ($countrycode == 'FR') { $countryfound = 1; // Definition des dates feriees fixes if ($jour == 1 && $mois == 1) { $ferie = true; } // 1er janvier if ($jour == 1 && $mois == 5) { $ferie = true; } // 1er mai if ($jour == 8 && $mois == 5) { $ferie = true; } // 5 mai if ($jour == 14 && $mois == 7) { $ferie = true; } // 14 juillet if ($jour == 15 && $mois == 8) { $ferie = true; } // 15 aout if ($jour == 1 && $mois == 11) { $ferie = true; } // 1 novembre if ($jour == 11 && $mois == 11) { $ferie = true; } // 11 novembre if ($jour == 25 && $mois == 12) { $ferie = true; } // 25 decembre // Calcul du jour de paques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if ($jour_paques == $jour && $mois_paques == $mois) { $ferie = true; } // Paques // Calcul du jour de l ascension (38 jours apres Paques) $date_ascension = mktime(date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), date("d", $date_paques) + 38, date("Y", $date_paques)); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); if ($jour_ascension == $jour && $mois_ascension == $mois) { $ferie = true; } //Ascension // Calcul de Pentecote (11 jours apres Paques) $date_pentecote = mktime(date("H", $date_ascension), date("i", $date_ascension), date("s", $date_ascension), date("m", $date_ascension), date("d", $date_ascension) + 11, date("Y", $date_ascension)); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); if ($jour_pentecote == $jour && $mois_pentecote == $mois) { $ferie = true; } //Pentecote // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. // Pentecoste is 50 days after Easter, Ascensione 40 if ($countrycode == 'IT') { $countryfound = 1; // Definition des dates feriees fixes if ($jour == 1 && $mois == 1) { $ferie = true; } // Capodanno if ($jour == 6 && $mois == 1) { $ferie = true; } // Epifania if ($jour == 25 && $mois == 4) { $ferie = true; } // Anniversario Liberazione if ($jour == 1 && $mois == 5) { $ferie = true; } // Festa del Lavoro if ($jour == 2 && $mois == 6) { $ferie = true; } // Festa della Repubblica if ($jour == 15 && $mois == 8) { $ferie = true; } // Ferragosto if ($jour == 1 && $mois == 11) { $ferie = true; } // Tutti i Santi if ($jour == 8 && $mois == 12) { $ferie = true; } // Immacolata Concezione if ($jour == 25 && $mois == 12) { $ferie = true; } // 25 decembre if ($jour == 26 && $mois == 12) { $ferie = true; } // Santo Stefano // Calcul du jour de paques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if ($jour_paques == $jour && $mois_paques == $mois) { $ferie = true; } // Paques // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } if ($countrycode == 'ES') { $countryfound = 1; // Definition des dates feriees fixes if ($jour == 1 && $mois == 1) { $ferie = true; } // Año nuevo if ($jour == 6 && $mois == 1) { $ferie = true; } // Día Reyes if ($jour == 1 && $mois == 5) { $ferie = true; } // 1 Mayo if ($jour == 15 && $mois == 8) { $ferie = true; } // 15 Agosto if ($jour == 12 && $mois == 10) { $ferie = true; } // Día Hispanidad if ($jour == 1 && $mois == 11) { $ferie = true; } // 1 noviembre if ($jour == 6 && $mois == 12) { $ferie = true; } // Constitución if ($jour == 8 && $mois == 12) { $ferie = true; } // Inmaculada if ($jour == 25 && $mois == 12) { $ferie = true; } // 25 diciembre // Calcul día de Pascua $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if ($jour_paques == $jour && $mois_paques == $mois) { $ferie = true; } // Paques // Viernes Santo $date_viernes = mktime(date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), date("d", $date_paques) - 2, date("Y", $date_paques)); $jour_viernes = date("d", $date_viernes); $mois_viernes = date("m", $date_viernes); if ($jour_viernes == $jour && $mois_viernes == $mois) { $ferie = true; } //Viernes Santo // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // Cas pays non defini if (!$countryfound) { // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // On incremente compteur if ($ferie) { $nbFerie++; } // Increase number of days (on go up into loop) $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); $i++; } return $nbFerie; }
/** * 获得用户笔记的月分布情况 * @param $uid */ public function getNoteProfileOfMonth($uid, $year, $month) { $calMonth = array(); $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); $inday = 1; for ($ws = 0; $ws < 6; $ws++) { $calWeek = array(); for ($date = 0; $date < 7; $date++) { $jd = unixtojd(mktime(0, 0, 0, $month, $inday, $year)); $calDay = cal_from_jd($jd, CAL_GREGORIAN); if ($calDay['dow'] == $date & $inday <= $daysInMonth) { $daily = array(); $daily['date'] = $inday; $daily['note_num'] = $this->getUserDailyNotesNumb($uid, $month, $inday, $year); array_push($calWeek, $daily); $inday++; } else { array_push($calWeek, 0); } } array_push($calMonth, $calWeek); } return $calMonth; }
<?php require '../../../db.php'; $user_id = mysql_real_escape_string($_POST['user_id']); $sql = "select school_id from users where user_id = " . $user_id; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $school_id = $row['school_id']; $chaiElul = 2457268; $jd = unixtojd(); $amount = 40; switch ($school_id) { case 61: if ($jd > $chaiElul) { $amount = 55; } else { $amount = 45; } break; case 5: case 42: case 63: case 263: if ($jd > 2457269) { $amount = 50; } break; case 3: case 49: case 81: case 185:
/** * Startup activity */ public function __construct() { global $WT_TREE; parent::__construct(); $this->setPageTitle(I18N::translate('Lifespans')); $this->facts = explode('|', WT_EVENTS_BIRT . '|' . WT_EVENTS_DEAT . '|' . WT_EVENTS_MARR . '|' . WT_EVENTS_DIV); $tmp = explode('\\', get_class(I18N::defaultCalendar())); $cal = strtolower(array_pop($tmp)); $this->defaultCalendar = str_replace('calendar', '', $cal); $filterPids = false; // Request parameters $clear = Filter::getBool('clear'); $newpid = Filter::get('newpid', WT_REGEX_XREF); $addfam = Filter::getBool('addFamily'); $this->place = Filter::get('place'); $this->beginYear = Filter::getInteger('beginYear', 0, PHP_INT_MAX, null); $this->endYear = Filter::getInteger('endYear', 0, PHP_INT_MAX, null); $this->calendar = Filter::get('calendar', null, $this->defaultCalendar); $this->strictDate = Filter::getBool('strictDate'); // Set up base color parameters $this->colors['M'] = new ColorGenerator(240, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE * -1); $this->colors['F'] = new ColorGenerator(00, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE); // Build a list of people based on the input parameters if ($clear) { // Empty list & reset form $xrefs = array(); $this->place = null; $this->beginYear = null; $this->endYear = null; $this->calendar = $this->defaultCalendar; } elseif ($this->place) { // Get all individual & family records found for a place $this->place_obj = new Place($this->place, $WT_TREE); $xrefs = Database::prepare("SELECT DISTINCT `i_id` FROM `##placelinks`" . " JOIN `##individuals` ON `pl_gid`=`i_id` AND `pl_file`=`i_file`" . " WHERE `i_file`=:tree_id" . " AND `pl_p_id`=:place_id" . " UNION" . " SELECT DISTINCT `f_id` FROM `##placelinks`" . " JOIN `##families` ON `pl_gid`=`f_id` AND `pl_file`=`f_file`" . " WHERE `f_file`=:tree_id" . " AND `pl_p_id`=:place_id")->execute(array('tree_id' => $WT_TREE->getTreeId(), 'place_id' => $this->place_obj->getPlaceId()))->fetchOneColumn(); } else { // Modify an existing list of records $xrefs = Session::get(self::SESSION_DATA, array()); if ($newpid) { $xrefs = array_merge($xrefs, $this->addFamily(Individual::getInstance($newpid, $WT_TREE), $addfam)); $xrefs = array_unique($xrefs); } elseif (!$xrefs) { $xrefs = $this->addFamily($this->getSignificantIndividual(), false); } } $tmp = $this->getCalendarDate(unixtojd()); $this->currentYear = $tmp->today()->y; $tmp = strtoupper(strtr($this->calendar, array('jewish' => 'hebrew', 'french' => 'french r'))); $this->calendarEscape = sprintf('@#D%s@', $tmp); if ($xrefs) { // ensure date ranges are valid in preparation for filtering list if ($this->beginYear || $this->endYear) { $filterPids = true; if (!$this->beginYear) { $tmp = new Date($this->calendarEscape . ' 1'); $this->beginYear = $tmp->minimumDate()->y; } if (!$this->endYear) { $this->endYear = $this->currentYear; } $this->startDate = new Date($this->calendarEscape . $this->beginYear); $this->endDate = new Date($this->calendarEscape . $this->endYear); } // Test each xref to see if the search criteria are met foreach ($xrefs as $key => $xref) { $valid = false; $person = Individual::getInstance($xref, $WT_TREE); if ($person) { if ($person->canShow()) { foreach ($person->getFacts() as $fact) { if ($this->checkFact($fact)) { $this->people[] = $person; $valid = true; break; } } } } else { $family = Family::getInstance($xref, $WT_TREE); if ($family && $family->canShow() && $this->checkFact($family->getMarriage())) { $valid = true; $this->people[] = $family->getHusband(); $this->people[] = $family->getWife(); } } if (!$valid) { unset($xrefs[$key]); // no point in storing a xref if we can't use it } } Session::put(self::SESSION_DATA, $xrefs); } else { Session::forget(self::SESSION_DATA); } $this->people = array_filter(array_unique($this->people)); $count = count($this->people); if ($count) { // Build the subtitle if ($this->place && $filterPids) { $this->subtitle = I18N::plural('%s individual with events in %s between %s and %s', '%s individuals with events in %s between %s and %s', $count, I18N::number($count), $this->place, $this->startDate->display(false, '%Y'), $this->endDate->display(false, '%Y')); } elseif ($this->place) { $this->subtitle = I18N::plural('%s individual with events in %s', '%s individuals with events in %s', $count, I18N::number($count), $this->place); } elseif ($filterPids) { $this->subtitle = I18N::plural('%s individual with events between %s and %s', '%s individuals with events between %s and %s', $count, I18N::number($count), $this->startDate->display(false, '%Y'), $this->endDate->display(false, '%Y')); } else { $this->subtitle = I18N::plural('%s individual', '%s individuals', $count, I18N::number($count)); } // Sort the array in order of birth year usort($this->people, function (Individual $a, Individual $b) { return Date::compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }); //Find the mimimum birth year and maximum death year from the individuals in the array. $bdate = $this->getCalendarDate($this->people[0]->getEstimatedBirthDate()->minimumJulianDay()); $minyear = $bdate->y; $that = $this; // PHP5.3 cannot access $this inside a closure $maxyear = array_reduce($this->people, function ($carry, Individual $item) use($that) { $date = $that->getCalendarDate($item->getEstimatedDeathDate()->maximumJulianDay()); return max($carry, $date->y); }, 0); } elseif ($filterPids) { $minyear = $this->endYear; $maxyear = $this->endYear; } else { $minyear = $this->currentYear; $maxyear = $this->currentYear; } $maxyear = min($maxyear, $this->currentYear); // Limit maximum year to current year as we can't forecast the future $minyear = min($minyear, $maxyear - $WT_TREE->getPreference('MAX_ALIVE_AGE')); // Set default minimum chart length $this->timelineMinYear = (int) floor($minyear / 10) * 10; // round down to start of the decade $this->timelineMaxYear = (int) ceil($maxyear / 10) * 10; // round up to start of next decade }
/** * Get today’s date in the current calendar. * * @return int[] */ public function todayYmd() { return $this->calendar->jdToYmd(unixtojd()); }
/** * Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp * Called by function num_open_day * * @param timestamp $timestampStart Timestamp de debut * @param timestamp $timestampEnd Timestamp de fin * @param string $countrycode Country code * @return int Nombre de jours feries */ function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR') { $nbFerie = 0; while ($timestampStart != $timestampEnd) { $ferie = false; $countryfound = 0; $jour = date("d", $timestampStart); $mois = date("m", $timestampStart); $annee = date("Y", $timestampStart); if ($countrycode == 'FR') { $countryfound = 1; // Definition des dates feriees fixes if ($jour == 1 && $mois == 1) { $ferie = true; } // 1er janvier if ($jour == 1 && $mois == 5) { $ferie = true; } // 1er mai if ($jour == 8 && $mois == 5) { $ferie = true; } // 5 mai if ($jour == 14 && $mois == 7) { $ferie = true; } // 14 juillet if ($jour == 15 && $mois == 8) { $ferie = true; } // 15 aout if ($jour == 1 && $mois == 11) { $ferie = true; } // 1 novembre if ($jour == 11 && $mois == 11) { $ferie = true; } // 11 novembre if ($jour == 25 && $mois == 12) { $ferie = true; } // 25 decembre // Calcul du jour de paques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if ($jour_paques == $jour && $mois_paques == $mois) { $ferie = true; } // Paques // Calcul du jour de l ascension (38 jours apres Paques) $date_ascension = mktime(date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), date("d", $date_paques) + 38, date("Y", $date_paques)); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); if ($jour_ascension == $jour && $mois_ascension == $mois) { $ferie = true; } //Ascension // Calcul de Pentecote (11 jours apres Paques) $date_pentecote = mktime(date("H", $date_ascension), date("i", $date_ascension), date("s", $date_ascension), date("m", $date_ascension), date("d", $date_ascension) + 11, date("Y", $date_ascension)); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); if ($jour_pentecote == $jour && $mois_pentecote == $mois) { $ferie = true; } //Pentecote // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. // Pentecoste is 50 days after Easter, Ascensione 40 if ($countrycode == 'IT') { $countryfound = 1; // Definition des dates feriees fixes if ($jour == 1 && $mois == 1) { $ferie = true; } // Capodanno if ($jour == 6 && $mois == 1) { $ferie = true; } // Epifania if ($jour == 25 && $mois == 4) { $ferie = true; } // Anniversario Liberazione if ($jour == 1 && $mois == 5) { $ferie = true; } // Festa del Lavoro if ($jour == 2 && $mois == 6) { $ferie = true; } // Festa della Repubblica if ($jour == 15 && $mois == 8) { $ferie = true; } // Ferragosto if ($jour == 1 && $mois == 11) { $ferie = true; } // Tutti i Santi if ($jour == 8 && $mois == 12) { $ferie = true; } // Immacolata Concezione if ($jour == 25 && $mois == 12) { $ferie = true; } // 25 decembre if ($jour == 26 && $mois == 12) { $ferie = true; } // Santo Stefano // Calcul du jour de paques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if ($jour_paques == $jour && $mois_paques == $mois) { $ferie = true; } // Paques // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // Cas pays non defini if (!$countryfound) { // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if ($jour_semaine == 0 || $jour_semaine == 6) { $ferie = true; } //Samedi (6) et dimanche (0) } // On incremente compteur if ($ferie) { $nbFerie++; } // Incrementation du nombre de jour (on avance dans la boucle) $jour++; $timestampStart = mktime(0, 0, 0, $mois, $jour, $annee); } return $nbFerie; }
function hanukkahStart($year = null) { $reference = ($year == '2021' || $year == '2032' ? '11/1/' : '12/1/') . ($year !== null ? $year : date('Y')); list($month, $day, $year) = explode("/", jdtojewish(unixtojd(strtotime($reference)))); return jdtounix(jewishtojd(3, 25, $year)); }