本文整理汇总了PHP中CDate::getHour方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::getHour方法的具体用法?PHP CDate::getHour怎么用?PHP CDate::getHour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::getHour方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 CDate($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) {
示例2: calcFinish
public function calcFinish($durn, $durnType)
{
// since one will alter the date ($this) one better copies it to a new instance
$f = new CDate();
$f->copy($this);
// get w2P time constants
$cal_day_start = intval(w2PgetConfig('cal_day_start'));
$cal_day_end = intval(w2PgetConfig('cal_day_end'));
$workHours = intval(w2PgetConfig('daily_working_hours'));
$workingDays = w2PgetConfig('cal_working_days');
$working_days = explode(',', $workingDays);
//temporary variables
$inc = floor($durn);
$hoursToAddToLastDay = 0;
$hoursToAddToFirstDay = $durn;
$fullWorkingDays = 0;
$int_st_hour = $f->getHour();
//catch the gap between the working hours and the open hours (like lunch periods)
$workGap = $cal_day_end - $cal_day_start - $workHours;
// calculate the number of non-working days
$k = 7 - count($working_days);
$durnMins = ($durn - $inc) * 60;
if ($f->getMinute() + $durnMins >= 60) {
$inc++;
}
$mins = ($f->getMinute() + $durnMins) % 60;
if ($mins > 38) {
$f->setMinute(45);
} elseif ($mins > 23) {
$f->setMinute(30);
} elseif ($mins > 8) {
$f->setMinute(15);
} else {
$f->setMinute(0);
}
// jump over to the first working day
for ($i = 0; $i < $k; $i++) {
if (array_search($f->getDayOfWeek(), $working_days) === false) {
$f->addDays(1);
}
}
if ($durnType == 24) {
if ($f->getHour() == $cal_day_start && $f->getMinute() == 0) {
$fullWorkingDays = ceil($inc);
$f->setMinute(0);
} else {
$fullWorkingDays = ceil($inc) + 1;
}
// Include start day as a working day (if it is one)
if (!(array_search($f->getDayOfWeek(), $working_days) === false)) {
$fullWorkingDays--;
}
for ($i = 0; $i < $fullWorkingDays; $i++) {
$f->addDays(1);
if (array_search($f->getDayOfWeek(), $working_days) === false) {
$i--;
}
}
if ($f->getHour() == $cal_day_start && $f->getMinute() == 0) {
$f->setHour($cal_day_end);
$f->setMinute(0);
}
} else {
$hoursToAddToFirstDay = $inc;
if ($f->getHour() + $inc > $cal_day_end - $workGap) {
$hoursToAddToFirstDay = $cal_day_end - $workGap - $f->getHour();
}
if ($hoursToAddToFirstDay > $workHours) {
$hoursToAddToFirstDay = $workHours;
}
$inc -= $hoursToAddToFirstDay;
$hoursToAddToLastDay = $inc % $workHours;
$fullWorkingDays = floor(($inc - $hoursToAddToLastDay) / $workHours);
if ($hoursToAddToLastDay <= 0 && !($hoursToAddToFirstDay == $workHours)) {
$f->setHour($f->getHour() + $hoursToAddToFirstDay);
} elseif ($hoursToAddToLastDay == 0) {
$f->setHour($f->getHour() + $hoursToAddToFirstDay + $workGap);
} else {
$f->setHour($cal_day_start + $hoursToAddToLastDay);
$f->addDays(1);
}
if (($f->getHour() == $cal_day_end || $f->getHour() - $int_st_hour == $workHours + $workGap) && $mins > 0) {
$f->addDays(1);
$f->setHour($cal_day_start);
}
// boolean for setting later if we just found a non-working day
// and therefore do not have to add a day in the next loop
// (which would have caused to not respecting multiple non-working days after each other)
$g = false;
for ($i = 0, $i_cmp = ceil($fullWorkingDays); $i < $i_cmp; $i++) {
if (!$g) {
$f->addHours(1);
}
$g = false;
// calculate overriden non-working days
if (array_search($f->getDayOfWeek(), $working_days) === false) {
$f->addDays(1);
$i--;
$g = true;
}
//.........这里部分代码省略.........
示例3: check
public function check()
{
// ensure changes to check boxes and select lists are honoured
$this->event_private = intval($this->event_private);
$this->event_type = intval($this->event_type);
$this->event_cwd = intval($this->event_cwd);
//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.
if ($this->event_recurs) {
$start_date = new CDate($this->event_start_date);
$end_date = new CDate($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);
}
return null;
}
示例4: arraySelect
<input type="text" name="start_date" id="start_date" value="<?php
echo $start_date ? $start_date->format($df) : "";
?>
" class="text" disabled="disabled" />
<a href="#" onClick="popCalendar(document.datesFrm.start_date)">
<img src="./images/calendar.gif" width="24" height="12" alt="<?php
echo $AppUI->_('Calendar');
?>
" border="0">
</a>
</td>
<td>
<table><tr>
<?php
echo "<td>" . arraySelect($hours, "start_hour", 'size="1" onchange="setAMPM(this)" class="text"', $start_date ? $start_date->getHour() : $start) . "</td><td>" . " : " . "</td>";
echo "<td>" . arraySelect($minutes, "start_minute", 'size="1" class="text"', $start_date ? $start_date->getMinute() : "0") . "</td>";
if (stristr($AppUI->getPref('TIMEFORMAT'), "%p")) {
echo '<td><input type="text" name="start_hour_ampm" id="start_hour_ampm" value="' . ($start_date ? $start_date->getAMPM() : ($start > 11 ? "pm" : "am")) . '" disabled="disabled" class="text" size="2" /></td>';
}
?>
</tr></table>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php
echo $AppUI->_('Finish Date');
?>
</td>
<td nowrap="nowrap">
<input type="hidden" name="task_end_date" id="task_end_date" value="<?php
示例5: intval
function calc_end_date($start_date = null, $durn = '8', $durnType = '1')
{
global $AppUI;
$cal_day_start = intval(dPgetConfig('cal_day_start'));
$cal_day_end = intval(dPgetConfig('cal_day_end'));
$daily_working_hours = intval(dPgetConfig('daily_working_hours'));
$s = new CDate($start_date);
$e = $s;
$inc = $durn;
$full_working_days = 0;
$hours_to_add_to_last_day = 0;
$hours_to_add_to_first_day = $durn;
// Calc the end date
if ($durnType == 24) {
// Units are full days
$full_working_days = ceil($durn);
for ($i = 0; $i < $full_working_days; $i++) {
$e->addDays(1);
$e->setTime($cal_day_start, '0', '0');
if (!$e->isWorkingDay()) {
$full_working_days++;
}
}
$e->setHour($s->getHour());
} else {
// Units are hours
// First partial day
if ($s->getHour() + $inc > $cal_day_end) {
// Account hours for partial work day
$hours_to_add_to_first_day = $cal_day_end - $s->getHour();
if ($hours_to_add_to_first_day > $daily_working_hours) {
$hours_to_add_to_first_day = $daily_working_hours;
}
$inc -= $hours_to_add_to_first_day;
$hours_to_add_to_last_day = $inc % $daily_working_hours;
// number of full working days remaining
$full_working_days = round(($inc - $hours_to_add_to_last_day) / $daily_working_hours);
if ($hours_to_add_to_first_day != 0) {
while (1) {
// Move on to the next workday
$e->addDays(1);
$e->setTime($cal_day_start, '0', '0');
if ($e->isWorkingDay()) {
break;
}
}
}
} else {
// less than one day's work, update the hour and be done..
$e->setHour($e->getHour() + $hours_to_add_to_first_day);
}
// Full days
for ($i = 0; $i < $full_working_days; $i++) {
$e->addDays(1);
$e->setTime($cal_day_start, '0', '0');
if (!$e->isWorkingDay()) {
$full_working_days++;
}
}
// Last partial day
if (!($full_working_days == 0 && $hours_to_add_to_last_day == 0)) {
$e->setHour($cal_day_start + $hours_to_add_to_last_day);
}
}
// Go to start of prev work day if current work day hasn't begun
if ($durn != 0) {
$e = $this->prev_working_day($e);
}
return $e;
}
示例6: void
?>
', 'datesFrm', null, true)" href="javascript: void(0);">
<img src="<?php
echo w2PfindImage('calendar.gif');
?>
" width="24" height="12" alt="<?php
echo $AppUI->_('Calendar');
?>
" border="0" />
</a>
</td>
<td>
<table><tr>
<?php
echo '<td>' . arraySelect($hours, 'start_hour', 'size="1" onchange="setAMPM(this)" class="text"', $start_date ? $start_date->getHour() : $start) . '</td><td> : </td>';
echo '<td>' . arraySelect($minutes, 'start_minute', 'size="1" class="text"', $start_date ? $start_date->getMinute() : '0') . '</td>';
if (stristr($AppUI->getPref('TIMEFORMAT'), '%p')) {
echo '<td><input type="text" name="start_hour_ampm" id="start_hour_ampm" value="' . ($start_date ? $start_date->getAMPM() : ($start > 11 ? 'pm' : 'am')) . '" disabled="disabled" class="text" size="2" /></td>';
}
?>
</tr></table>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php
echo $AppUI->_('Finish Date');
?>
</td>
<td nowrap="nowrap">
<input type='hidden' id='task_end_date' name='task_end_date' value='<?php