private static function PICalc($str, $y1, $y2 = false, $m1 = false, $m2 = false, $d1 = false, $d2 = false, $t1 = false, $t2 = false) { $duration = 0; if (is_numeric($d1)) { if (is_numeric($d2)) { if ($d1 > $d2) { throw new ADEIException(translate("Invalid interval (%s) is specified: Start-day is above of end-day", $str)); } } else { $d2 = $d1; } if (!$t1) { $duration = 86400; } $madd = 0; } else { $d1 = 1; $d2 = 1; $madd = 1; } if ($m1) { $m1 = INTERVAL::FindMonthByName($m1); if ($m2) { $m2 = INTERVAL::FindMonthByName($m2) + $madd; if ($m1 > $m2) { throw new ADEIException(translate("Invalid interval (%s) is specified: Start-month is above of end-month", $str)); } } else { $m2 = $m1 + $madd; } if ($m2 == 13) { $m2 = 1; $yadd = 1; } else { $yadd = 0; } } else { $m1 = 1; $m2 = 1; $yadd = 1; } if (!is_numeric($y1)) { $y1 = date('Y'); if (strtotime("{$y1}-{$m1}-01T00:00:00") > date('U')) { $y1--; } } if (is_numeric($y2)) { if ($y1 > $y2) { throw new ADEIException(translate("Invalid interval (%s) is specified: Start-year is above of end-year", $str)); } $y2 += $yadd; } else { $y2 = $y1 + $yadd; } if ($t1) { if (!$t2) { throw new ADEIException(translate("Invalid interval (%s) is specified", $str)); } $num = substr_count($t1, ":"); for ($i = $num; $i < 2; $i++) { $t1 .= ":00"; } $num = substr_count($t2, ":"); for ($i = $num; $i < 2; $i++) { $t2 .= ":00"; } } else { $t1 = "00:00:00"; $t2 = "00:00:00"; } $from = "{$y1}-{$m1}-{$d1}T{$t1}"; $to = "{$y2}-{$m2}-{$d2}T{$t2}"; return array($from, $to, $duration); }