本文整理匯總了PHP中SugarDateTime::setTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP SugarDateTime::setTime方法的具體用法?PHP SugarDateTime::setTime怎麽用?PHP SugarDateTime::setTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SugarDateTime
的用法示例。
在下文中一共展示了SugarDateTime::setTime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: queryMonth
/**
* Create query from the beginning to the end of certain month
* @param array $layout_def
* @param SugarDateTime $month
*/
protected function queryMonth($layout_def, $month)
{
$begin = $month->setTime(0, 0, 0);
$end = clone $begin;
$end->setDate($begin->year, $begin->month, $begin->days_in_month)->setTime(23, 59, 59);
return $this->get_start_end_date_filter($layout_def, $begin->asDb(), $end->asDb());
}
示例2: createSugarIcalTodo
/**
* Create a todo entry for the given task.
*
* @param UserBean $user_bean the current UserBean
* @param Task $task the task for the todo entry
* @param string $moduleName the name of the task module
* @param string $dtstamp the current timestamp
* @return string the todo entry for the task
*/
protected function createSugarIcalTodo($user_bean, $task, $moduleName, $dtstamp)
{
global $sugar_config;
$ical_array = array();
$ical_array[] = array("BEGIN", "VTODO");
$validDueDate = isset($task->date_due) && $task->date_due != "" && $task->date_due != "0000-00-00";
$validDueTime = isset($task->time_due) && $task->time_due != "";
$dueYear = 1970;
$dueMonth = 1;
$dueDay = 1;
$dueHour = 0;
$dueMin = 0;
if ($validDueDate) {
$dateDueArr = explode("-", $task->date_due);
$dueYear = (int) $dateDueArr[0];
$dueMonth = (int) $dateDueArr[1];
$dueDay = (int) $dateDueArr[2];
if ($validDueTime) {
$timeDueArr = explode(":", $task->time_due);
$dueHour = (int) $timeDueArr[0];
$dueMin = (int) $timeDueArr[1];
}
}
$date_arr = array('day' => $dueDay, 'month' => $dueMonth, 'hour' => $dueHour, 'min' => $dueMin, 'year' => $dueYear);
$due_date_time = new SugarDateTime();
$due_date_time->setDate($dueYear, $dueMonth, $dueDay);
$due_date_time->setTime($dueHour, $dueMin);
$ical_array[] = array("DTSTART;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $this->getUtcDateTime($due_date_time)));
$ical_array[] = array("DTSTAMP", $dtstamp);
$ical_array[] = array("SUMMARY", $task->name);
$ical_array[] = array("UID", $task->id);
if ($validDueDate) {
$iCalDueDate = str_replace("-", "", $task->date_due);
if (strlen($iCalDueDate) > 8) {
$iCalDueDate = substr($iCalDueDate, 0, 8);
}
$ical_array[] = array("DUE;VALUE=DATE", $iCalDueDate);
}
if ($moduleName == "ProjectTask") {
$ical_array[] = array("DESCRIPTION:Project", $task->project_name . vCal::EOL . vCal::EOL . $task->description);
} else {
$ical_array[] = array("DESCRIPTION", $task->description);
}
$ical_array[] = array("URL;VALUE=URI", $sugar_config['site_url'] . "/index.php?module=" . $moduleName . "&action=DetailView&record=" . $task->id);
if ($task->status == 'Completed') {
$ical_array[] = array("STATUS", "COMPLETED");
$ical_array[] = array("PERCENT-COMPLETE", "100");
$ical_array[] = array("COMPLETED", $this->getUtcDateTime($due_date_time));
} else {
if (!empty($task->percent_complete)) {
$ical_array[] = array("PERCENT-COMPLETE", $task->percent_complete);
}
}
if ($task->priority == "Low") {
$ical_array[] = array("PRIORITY", "9");
} else {
if ($task->priority == "Medium") {
$ical_array[] = array("PRIORITY", "5");
} else {
if ($task->priority == "High") {
$ical_array[] = array("PRIORITY", "1");
}
}
}
$ical_array[] = array("END", "VTODO");
return vCal::create_ical_string_from_array($ical_array, true);
}
示例3: createSugarIcalTodo
/**
* Create a todo entry for the given task.
*
* @param UserBean $user_bean the current UserBean
* @param Task $task the task for the todo entry
* @param string $moduleName the name of the task module
* @param string $dtstamp the current timestamp
* @return string the todo entry for the task
*/
protected function createSugarIcalTodo($user_bean, $task, $moduleName, $dtstamp)
{
global $sugar_config;
$str = "";
$str .= "BEGIN:VTODO\n";
$validDueDate = isset($task->date_due) && $task->date_due != "" && $task->date_due != "0000-00-00";
$validDueTime = isset($task->time_due) && $task->time_due != "";
$dueYear = 1970;
$dueMonth = 1;
$dueDay = 1;
$dueHour = 0;
$dueMin = 0;
if ($validDueDate) {
$dateDueArr = split("-", $task->date_due);
$dueYear = (int) $dateDueArr[0];
$dueMonth = (int) $dateDueArr[1];
$dueDay = (int) $dateDueArr[2];
if ($validDueTime) {
$timeDueArr = split(":", $task->time_due);
$dueHour = (int) $timeDueArr[0];
$dueMin = (int) $timeDueArr[1];
}
}
$date_arr = array('day' => $dueDay, 'month' => $dueMonth, 'hour' => $dueHour, 'min' => $dueMin, 'year' => $dueYear);
$due_date_time = new SugarDateTime();
$due_date_time->setDate($dueYear, $dueMonth, $dueDay);
$due_date_time->setTime($dueHour, $dueMin);
$str .= "DTSTART;TZID=" . $user_bean->getPreference('timezone') . ":" . str_replace("Z", "", $this->getUtcDateTime($due_date_time)) . "\n";
$str .= "DTSTAMP:" . $dtstamp . "\n";
$str .= "SUMMARY:" . $task->name . "\n";
$str .= "UID:" . $task->id . "\n";
if ($validDueDate) {
$iCalDueDate = str_replace("-", "", $task->date_due);
if (strlen($iCalDueDate) > 8) {
$iCalDueDate = substr($iCalDueDate, 0, 8);
}
$str .= "DUE;VALUE=DATE:" . $iCalDueDate . "\n";
}
if ($moduleName == "ProjectTask") {
$str .= "DESCRIPTION:Project: " . $task->project_name . "\\n\\n" . $this->escapeNls($task->description) . "\n";
} else {
$str .= "DESCRIPTION:" . $this->escapeNls($task->description) . "\n";
}
$str .= "URL;VALUE=URI:" . $sugar_config['site_url'] . "/index.php?module=" . $moduleName . "&action=DetailView&record=" . $task->id . "\n";
if ($task->status == 'Completed') {
$str .= "STATUS:COMPLETED\n";
$str .= "PERCENT-COMPLETE:100\n";
$str .= "COMPLETED:" . $this->getUtcDateTime($due_date_time) . "\n";
} else {
if (!empty($task->percent_complete)) {
$str .= "PERCENT-COMPLETE:" . $task->percent_complete . "\n";
}
}
if ($task->priority == "Low") {
$str .= "PRIORITY:9\n";
} else {
if ($task->priority == "Medium") {
$str .= "PRIORITY:5\n";
} else {
if ($task->priority == "High") {
$str .= "PRIORITY:1\n";
}
}
}
$str .= "END:VTODO\n";
return $str;
}