本文整理汇总了PHP中w2p_Utilities_Date::getHour方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::getHour方法的具体用法?PHP w2p_Utilities_Date::getHour怎么用?PHP w2p_Utilities_Date::getHour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::getHour方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calcFinish
public function calcFinish($duration, $durationType)
{
// since one will alter the date ($this) one better copies it to a new instance
$finishDate = new w2p_Utilities_Date();
$finishDate->copy($this);
// get w2P time constants
$day_start_hour = intval(w2PgetConfig('cal_day_start'));
$day_end_hour = intval(w2PgetConfig('cal_day_end'));
$work_hours = intval(w2PgetConfig('daily_working_hours'));
$duration_in_minutes = $durationType == 24 ? $duration * $work_hours * 60 : $duration * 60;
// Jump to the first working day
while (!$finishDate->isWorkingDay()) {
$finishDate->addDays(1);
}
$first_day_minutes = min($day_end_hour * 60 - $finishDate->getHour() * 60 - $finishDate->getMinute(), $work_hours * 60, $duration_in_minutes);
$finishDate->addSeconds($first_day_minutes * 60);
$duration_in_minutes -= $first_day_minutes;
while ($duration_in_minutes != 0) {
// Jump to the next day
$finishDate->addDays(1);
// Reset date's time to the first hour in the morning
$finishDate->setTime($day_start_hour);
// Jump all non-working days
while (!$finishDate->isWorkingDay()) {
$finishDate->addDays(1);
}
$day_work_minutes = min($work_hours * 60, $duration_in_minutes);
$finishDate->addSeconds($day_work_minutes * 60);
$duration_in_minutes -= $day_work_minutes;
}
return $finishDate;
}
示例2: hook_preStore
protected function hook_preStore()
{
parent::hook_preStore();
if (!$this->event_recurs) {
$this->event_times_recuring = 0;
} else {
//If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
//so that the event starts recurring from the start day onwards n times after the start date for the period given
//Meaning: The event end date day is useless as far as recurring events are concerned.
$start_date = new w2p_Utilities_Date($this->event_start_date);
$end_date = new w2p_Utilities_Date($this->event_end_date);
$hour = $end_date->getHour();
$minute = $end_date->getMinute();
$end_date->setDate($start_date->getDate());
$end_date->setHour($hour);
$end_date->setMinute($minute);
$this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
// ensure changes to check boxes and select lists are honoured
$this->event_private = (int) $this->event_private;
$this->event_type = (int) $this->event_type;
$this->event_cwd = (int) $this->event_cwd;
$this->event_creator = (int) $this->event_creator ? $this->event_creator : $this->_AppUI->user_id;
$this->event_owner = (int) $this->event_owner ? $this->event_owner : $this->_AppUI->user_id;
$q = $this->_getQuery();
$this->event_updated = $q->dbfnNowWithTZ();
}
示例3: store
public function store(CAppUI $AppUI)
{
$perms = $AppUI->acl();
$stored = false;
if (!$this->event_recurs) {
$this->event_times_recuring = 0;
} else {
//If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
//so that the event starts recurring from the start day onwards n times after the start date for the period given
//Meaning: The event end date day is useless as far as recurring events are concerned.
$start_date = new w2p_Utilities_Date($this->event_start_date);
$end_date = new w2p_Utilities_Date($this->event_end_date);
$hour = $end_date->getHour();
$minute = $end_date->getMinute();
$end_date->setDate($start_date->getDate());
$end_date->setHour($hour);
$end_date->setMinute($minute);
$this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
// ensure changes to check boxes and select lists are honoured
$this->event_private = (int) $this->event_private;
$this->event_type = (int) $this->event_type;
$this->event_cwd = (int) $this->event_cwd;
$this->_error = $this->check();
if (count($this->_error)) {
return $this->_error;
}
$this->event_start_date = $AppUI->convertToSystemTZ($this->event_start_date);
$this->event_end_date = $AppUI->convertToSystemTZ($this->event_end_date);
/*
* TODO: I don't like the duplication on each of these two branches, but I
* don't have a good idea on how to fix it at the moment...
*/
if ($this->event_id && $perms->checkModuleItem('events', 'edit', $this->event_id)) {
if ($msg = parent::store()) {
return $msg;
}
$stored = true;
}
if (0 == $this->event_id && $perms->checkModuleItem('events', 'add')) {
if ($msg = parent::store()) {
return $msg;
}
$stored = true;
}
if ($stored) {
// TODO: I *really* don't like using the POST inside here..
$this->updateAssigned(explode(',', $_POST['event_assigned']));
$custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit');
$custom_fields->bind($_POST);
$sql = $custom_fields->store($this->event_id);
// Store Custom Fields
}
return $stored;
}
示例4: testGetHourInvalidHour
/**
* Tests getHour with an invalid Hour, this should break...
*/
public function testGetHourInvalidHour()
{
$date = new w2p_Utilities_Date('2010-11-06 25:00:00');
$this->assertEquals(25, $date->getHour());
}
示例5: count
}
require_once W2P_BASE_DIR . '/modules/calendar/links_events.php';
$html .= '</form>';
$html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">';
$rows = 0;
for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) {
$html .= '<tr>';
$tm = $this_day->format($tf);
$html .= '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>';
$timeStamp = $this_day->format('%H%M%S');
if (isset($events2[$timeStamp])) {
$count = count($events2[$timeStamp]);
for ($j = 0; $j < $count; $j++) {
$row = $events2[$timeStamp][$j];
$et = new w2p_Utilities_Date($row['event_end_date']);
$rows = ($et->getHour() * 60 + $et->getMinute() - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc;
$href = '?m=calendar&a=view&event_id=' . $row['event_id'];
$alt = $row['event_description'];
$html .= '<td class="event" rowspan="' . $rows . '" valign="top">';
$html .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
$html .= '<td>' . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar');
$html .= '</td><td> <b>' . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>';
$html .= w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true);
$html .= $href ? '<a href="' . $href . '" class="event">' : '';
$html .= $row['event_title'];
$html .= $href ? '</a>' : '';
$html .= w2PendTip();
$html .= '</td>';
}
} else {
if (--$rows <= 0) {
示例6: store
public function store()
{
$stored = false;
$q = $this->_getQuery();
if (!$this->event_recurs) {
$this->event_times_recuring = 0;
} else {
//If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
//so that the event starts recurring from the start day onwards n times after the start date for the period given
//Meaning: The event end date day is useless as far as recurring events are concerned.
$start_date = new w2p_Utilities_Date($this->event_start_date);
$end_date = new w2p_Utilities_Date($this->event_end_date);
$hour = $end_date->getHour();
$minute = $end_date->getMinute();
$end_date->setDate($start_date->getDate());
$end_date->setHour($hour);
$end_date->setMinute($minute);
$this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
// ensure changes to check boxes and select lists are honoured
$this->event_private = (int) $this->event_private;
$this->event_type = (int) $this->event_type;
$this->event_cwd = (int) $this->event_cwd;
$this->event_start_date = $this->_AppUI->convertToSystemTZ($this->event_start_date);
$this->event_end_date = $this->_AppUI->convertToSystemTZ($this->event_end_date);
/*
* TODO: I don't like the duplication on each of these two branches, but I
* don't have a good idea on how to fix it at the moment...
*/
if ($this->{$this->_tbl_key} && $this->canEdit()) {
$this->event_updated = $q->dbfnNowWithTZ();
$stored = parent::store();
}
if (0 == $this->{$this->_tbl_key} && $this->canCreate()) {
$this->event_created = $q->dbfnNowWithTZ();
$this->event_updated = $this->event_created;
$stored = parent::store();
}
return $stored;
}
示例7: strtotime
if ($bulk_task_start_date) {
$time = strtotime($bulk_task_start_date);
$upd_task->task_start_date = date('Y-m-d H:i:s', $time);
if ($add_task_bulk_time_keep) {
$tmp_start_date = new w2p_Utilities_Date($upd_task->task_start_date, $userTZ);
$tmp_start_date->setHour($start_date_old->getHour());
$tmp_start_date->setMinute($start_date_old->getMinute());
$upd_task->task_start_date = $tmp_start_date->format(FMT_DATETIME_MYSQL);
}
}
if ($bulk_task_end_date) {
$time = strtotime($bulk_task_end_date);
$upd_task->task_end_date = date('Y-m-d H:i:s', $time);
if ($add_task_bulk_time_keep) {
$tmp_end_date = new w2p_Utilities_Date($upd_task->task_end_date, $userTZ);
$tmp_end_date->setHour($end_date_old->getHour());
$tmp_end_date->setMinute($end_date_old->getMinute());
$upd_task->task_end_date = $tmp_end_date->format(FMT_DATETIME_MYSQL);
}
}
$result = $upd_task->store();
}
//Action: Modify Duration
if (isset($_POST['bulk_task_duration']) && $bulk_task_duration != '' && is_numeric($bulk_task_duration)) {
if ($upd_task->task_id) {
$upd_task->task_duration = $bulk_task_duration;
//set duration type to hours (1)
$upd_task->task_duration_type = $bulk_task_durntype ? $bulk_task_durntype : 1;
$result = $upd_task->store();
if (!$result) {
break;
示例8: updateTaskSummary
/**
* Updates the variable information on the task.
*
* @param int $notUsed not used
* @param int $task_id that task id of task this task log is for
*
* @return void
*
* @access protected
*/
protected function updateTaskSummary($notUsed = null, $task_id)
{
$task = new CTask();
$task->overrideDatabase($this->_query);
$task->load($task_id);
$q = $this->_getQuery();
if ($this->_perms->checkModuleItem('tasks', 'edit', $task_id)) {
if ($this->task_log_percent_complete <= 100) {
$q->addQuery('task_log_percent_complete, task_log_date');
$q->addTable('task_log');
$q->addWhere('task_log_task = ' . (int) $task_id);
$q->addOrder('task_log_date DESC, task_log_id DESC');
$q->setLimit(1);
$results = $q->loadHash();
$percentComplete = $results['task_log_percent_complete'];
} else {
$percentComplete = 100;
}
$old_end_date = new w2p_Utilities_Date($task->task_end_date);
$new_end_date = new w2p_Utilities_Date($this->task_log_task_end_date);
$new_end_date->setHour($old_end_date->getHour());
$new_end_date->setMinute($old_end_date->getMinute());
$task_end_date = $new_end_date->format(FMT_DATETIME_MYSQL);
/*
* We're using a database update here instead of store() because a
* bunch of other things happen when you call store().. like the
* processing of contacts, departments, etc.
*/
$q = $this->_getQuery();
$q->addTable('tasks');
$q->addUpdate('task_percent_complete', $percentComplete);
$q->addUpdate('task_end_date', $task_end_date);
$q->addWhere('task_id = ' . (int) $task_id);
$success = $q->exec();
if (!$success) {
$this->_AppUI->setMsg($task->getError(), UI_MSG_ERROR, true);
}
$task->pushDependencies($task_id, $task_end_date);
}
$q->addQuery('SUM(task_log_hours)');
$q->addTable('task_log');
$q->addWhere('task_log_task = ' . (int) $task_id);
$totalHours = $q->loadResult();
$task->updateHoursWorked2($task_id, $totalHours);
$task->updateDynamics();
}