本文整理汇总了PHP中functions::date_diff_workaround方法的典型用法代码示例。如果您正苦于以下问题:PHP functions::date_diff_workaround方法的具体用法?PHP functions::date_diff_workaround怎么用?PHP functions::date_diff_workaround使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类functions
的用法示例。
在下文中一共展示了functions::date_diff_workaround方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEventsBarchart
function getEventsBarchart($confid, $treatLocalsSeparately = 0)
{
$cidcode = "";
if (is_array($confid)) {
foreach ($confid as $cid) {
$cidcode[] = "(E.e_code='" . $cid . "')";
}
} else {
$cidcode[] = "(E.e_code='" . $confid . "')";
}
// ------------------------------------------------------
// Query database
// ------------------------------------------------------
//TODO: if multiple $confids same day, add people without duplocation
$sql = "\n SELECT\n E.e_name,\n A.av_institute,\n A.av_email,\n A.av_city,\n FROM_UNIXTIME(V.v_start,'%Y-%m-%d') AS 'd0',\n FROM_UNIXTIME(V.v_end,'%Y-%m-%d') AS 'd1'\n FROM\n abs_visits AS V\n LEFT JOIN zzz_avatars AS A ON A.av_id=V.v_avid\n LEFT JOIN abs_events AS E ON E.e_code=SUBSTRING(V.v_code,1,4)\n WHERE\n (" . implode(" OR ", $cidcode) . ") AND (V.v_status <> 'STATUS_NO')\n ORDER BY\n V.v_start";
$res = $this->query($sql, IS_TESTSERVER);
// includes a call to connect
// ------------------------------------------------------
// Assemble $visit[] from resultset
// ------------------------------------------------------
$GLOBALS["eventTitle"] = "";
$visit = array();
if ($this->num_rows($res)) {
while ($cell = $this->next_record_assoc($res)) {
$isLocal = strpos(strtolower($cell["av_city"]), "stockholm") !== false || strpos(strtolower($cell["av_email"]), "kth.se") !== false || strpos(strtolower($cell["av_email"]), "su.se") !== false || strpos(strtolower($cell["av_email"]), "nordita.org") !== false ? 1 : 0;
$visit[$cell["av_email"]][] = array($cell["d0"], $cell["d1"], $isLocal);
$GLOBALS["eventTitle"] = $cell["e_name"];
}
// end while
}
$modvisit = array();
foreach ($visit as $email => $data) {
foreach ($data as $b) {
$b0 = min($b[1], $b[0]);
for ($i = 0; $i <= functions::date_diff_workaround($b[1], $b[0]); $i++) {
$adate = date("Y-m-d", strtotime($b0 . " + " . $i . " day"));
$vtype = "any";
if ($treatLocalsSeparately) {
$vtype = $b[2] ? "local" : "visitor";
}
$modvisit[$email][$vtype][$adate] = 1;
}
}
}
// ------------------------------------------------------
// Assemble $barchart[]
// ------------------------------------------------------
$barchart = array();
foreach ($modvisit as $email => $array) {
foreach ($array as $vtype => $days) {
foreach ($days as $adate => $data) {
$barchart[$adate][$vtype] = isset($barchart[$adate][$vtype]) ? $barchart[$adate][$vtype] + 1 : 1;
}
}
}
ksort($barchart);
/*
// ------------------------------------------------------
// Assemble $barchart[]
// ------------------------------------------------------
$barchart = array();
foreach ($visit as $b) {
$b0 = min($b[1],$b[0]);
for ($i=0; $i<=functions::date_diff_workaround($b[1],$b[0]); $i++) {
$adate = date("Y-m-d",strtotime($b0 . " + " . $i . " day"));
if ($treatLocalsSeparately) {
if ($b[2]) {
$barchart[$adate]["local"] = (isset($barchart[$adate]["local"])) ? $barchart[$adate]["local"]+1 : 1;
} else {
$barchart[$adate]["visitor"] = (isset($barchart[$adate]["visitor"])) ? $barchart[$adate]["visitor"]+1 : 1;
}
} else {
$barchart[$adate] = (isset($barchart[$adate])) ? $barchart[$adate]+1 : 1;
}
}
}
ksort($barchart);
*/
return $barchart;
}
示例2: calculateVisitors
private static function calculateVisitors($personData, $yearfrom = VM_START_YEAR, $yearto = "", $mindays = 1)
{
if (empty($yearto)) {
$yearto = date("Y");
}
if ($yearfrom > $yearto) {
$yearfrom = VM_START_YEAR;
$yearto = date("Y");
}
$visits = array();
foreach ($personData as $data) {
$yearVisitStart = date("Y", $data["visit_start"]);
$yearVisitEnd = date("Y", $data["visit_end"]);
if ($yearVisitStart <= $yearto && $yearfrom <= $yearVisitEnd) {
if ($yearVisitStart < $yearfrom) {
$yearVisitStart = $yearfrom;
$data["visit_start"] = mktime(0, 0, 0, 1, 1, $yearfrom);
}
if ($yearto < $yearVisitEnd) {
$yearVisitEnd = $yearto;
$data["visit_end"] = mktime(0, 0, 0, 12, 31, $yearto);
}
$thisApp = array();
// some ad hoc exclusions
if ($data["firstname"] . " " . $data["lastname"] == 'Larus Thorlacius') {
continue;
}
if ($data["firstname"] . " " . $data["lastname"] == 'Troels Harmark') {
continue;
}
if ($data["firstname"] . " " . $data["lastname"] == 'John Hertz') {
continue;
}
if ($data["firstname"] . " " . $data["lastname"] == 'Dhrubaditya Mitra') {
if (date("Y", $data["visit_start"]) > 2008) {
continue;
}
$data["res"] = 'in';
$data["nordic"] = 0;
}
$name = $data["firstname"] . " " . $data["lastname"];
if (!isset($visits[$name])) {
$visits[$name]["country"] = !empty($data["res"]) ? strtolower($data["res"]) : "";
$visits[$name]["totdays"] = 0;
$visits[$name]["institute"] = $data["institute"];
}
$visits[$name]["interval"][] = functions::readableDateInterval(date("Y-m-d", $data["visit_start"]), date("Y-m-d", $data["visit_end"]), true);
$days = functions::date_diff_workaround(date("Y-m-d", $data["visit_start"]), date("Y-m-d", $data["visit_end"]));
if (!$days) {
$days = 1;
}
// count only nights, but if visitors arrives and leaves the same day, count as one:
$visits[$name]["totdays"] = $visits[$name]["totdays"] + $days;
$visits[$name]["days"][] = $days;
}
}
// end foreach
foreach ($visits as $name => $data) {
if ($data["totdays"] < $mindays) {
unset($visits[$name]);
}
}
return $visits;
}