本文整理汇总了PHP中w2p_Utilities_Date::setTime方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::setTime方法的具体用法?PHP w2p_Utilities_Date::setTime怎么用?PHP w2p_Utilities_Date::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::setTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calcDuration
function calcDuration($start_date, $start_hour, $start_minute, $end_date, $end_hour, $end_minute, $duration_type)
{
$year = substr($start_date, 0, 4);
$month = substr($start_date, 4, 2);
$day = substr($start_date, 6, 2);
$startDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day);
$startDate->setTime($start_hour, $start_minute);
$year = substr($end_date, 0, 4);
$month = substr($end_date, 4, 2);
$day = substr($end_date, 6, 2);
$endDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day);
$endDate->setTime($end_hour, $end_minute);
$duration = $startDate->calcDuration($endDate);
if (intval($duration_type) == 24) {
$workHours = intval(w2PgetConfig('daily_working_hours'));
$duration = $duration / $workHours;
}
$response = new xajaxResponse();
$response->assign('task_duration', 'value', $duration);
return $response;
}
示例2: array
$minical->showWeek = false;
$minical->clickMonth = true;
$minical->setLinkFunctions('clickDay');
$first_time = new w2p_Utilities_Date($cal->prev_month);
$first_time->setDay(1);
$first_time->setTime(0, 0, 0);
$last_time = new w2p_Utilities_Date($cal->prev_month);
$last_time->setDay($cal->prev_month->getDaysInMonth());
$last_time->setTime(23, 59, 59);
$links = array();
getTaskLinks($first_time, $last_time, $links, 20, $company_id, true);
getEventLinks($first_time, $last_time, $links, 20);
$minical->setEvents($links);
echo '<table class="std" cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
echo '<td valign="top" align="center" width="220">' . $minical->show() . '</td>';
echo '<td valign="top" align="center" width="75%"> </td>';
$minical->setDate($cal->next_month);
$first_time = new w2p_Utilities_Date($cal->next_month);
$first_time->setDay(1);
$first_time->setTime(0, 0, 0);
$last_time = new w2p_Utilities_Date($cal->next_month);
$last_time->setDay($cal->next_month->getDaysInMonth());
$last_time->setTime(23, 59, 59);
$links = array();
getTaskLinks($first_time, $last_time, $links, 20, $company_id, true);
getEventLinks($first_time, $last_time, $links, 20, true);
$minical->setEvents($links);
echo '<td valign="top" align="center" width="220">' . $minical->show() . '</td>';
echo '</tr></table>';
?>
</td></tr></table>
示例3: store
public function store(CAppUI $AppUI = null)
{
global $AppUI;
$perms = $AppUI->acl();
$stored = false;
$this->w2PTrimAll();
// ensure changes of state in checkboxes is captured
$this->project_active = (int) $this->project_active;
$this->project_private = (int) $this->project_private;
$this->project_target_budget = filterCurrency($this->project_target_budget);
$this->project_actual_budget = filterCurrency($this->project_actual_budget);
// Make sure project_short_name is the right size (issue for languages with encoded characters)
$this->project_short_name = mb_substr($this->project_short_name, 0, 10);
if (empty($this->project_end_date)) {
$this->project_end_date = null;
}
$this->_error = $this->check();
if (count($this->_error)) {
return $this->_error;
}
$this->project_id = (int) $this->project_id;
// convert dates to SQL format first
if ($this->project_start_date) {
$date = new w2p_Utilities_Date($this->project_start_date);
$this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
}
if ($this->project_end_date) {
$date = new w2p_Utilities_Date($this->project_end_date);
$date->setTime(23, 59, 59);
$this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
}
if ($this->project_actual_end_date) {
$date = new w2p_Utilities_Date($this->project_actual_end_date);
$this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
}
// check project parents and reset them to self if they do not exist
if (!$this->project_parent) {
$this->project_parent = $this->project_id;
$this->project_original_parent = $this->project_id;
} else {
$parent_project = new CProject();
$parent_project->load($this->project_parent);
$this->project_original_parent = $parent_project->project_original_parent;
}
if (!$this->project_original_parent) {
$this->project_original_parent = $this->project_id;
}
/*
* 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...
*/
$q = $this->_query;
$this->project_updated = $q->dbfnNowWithTZ();
if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) {
if ($msg = parent::store()) {
return $msg;
}
$stored = true;
}
if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
$this->project_created = $q->dbfnNowWithTZ();
if ($msg = parent::store()) {
return $msg;
}
if (0 == $this->project_parent || 0 == $this->project_original_parent) {
$this->project_parent = $this->project_id;
$this->project_original_parent = $this->project_id;
if ($msg = parent::store()) {
return $msg;
}
}
$stored = true;
}
//split out related departments and store them seperatly.
$q->setDelete('project_departments');
$q->addWhere('project_id=' . (int) $this->project_id);
$q->exec();
$q->clear();
if ($this->project_departments) {
foreach ($this->project_departments as $department) {
if ($department) {
$q->addTable('project_departments');
$q->addInsert('project_id', $this->project_id);
$q->addInsert('department_id', $department);
$q->exec();
$q->clear();
}
}
}
//split out related contacts and store them seperatly.
$q->setDelete('project_contacts');
$q->addWhere('project_id=' . (int) $this->project_id);
$q->exec();
$q->clear();
if ($this->project_contacts) {
foreach ($this->project_contacts as $contact) {
if ($contact) {
$q->addTable('project_contacts');
$q->addInsert('project_id', $this->project_id);
$q->addInsert('contact_id', $contact);
//.........这里部分代码省略.........
示例4: clash_suggest
function clash_suggest(w2p_Core_CAppUI $AppUI, $cal_sdf)
{
global $m, $a;
$obj = new CEvent();
$obj->bind($_SESSION['add_event_post']);
$start_date = new w2p_Utilities_Date($obj->event_start_date);
$end_date = new w2p_Utilities_Date($obj->event_end_date);
$df = $AppUI->getPref('SHDATEFORMAT');
$start_secs = $start_date->getTime();
$end_secs = $end_date->getTime();
$duration = (int) (($end_secs - $start_secs) / 60);
$titleBlock = new w2p_Theme_TitleBlock('Suggest Alternative Event Time', 'myevo-appointments.png', $m, $m . '.' . $a);
$titleBlock->show();
$calurl = W2P_BASE_URL . '/index.php?m=calendar&a=clash&event_id=' . $obj->event_id;
$times = array();
$t = new w2p_Utilities_Date();
$t->setTime(0, 0, 0);
if (!defined('LOCALE_TIME_FORMAT')) {
define('LOCALE_TIME_FORMAT', '%I:%M %p');
}
for ($m = 0; $m < 60; $m++) {
$times[$t->format('%H%M%S')] = $t->format(LOCALE_TIME_FORMAT);
$t->addSeconds(1800);
}
/* TODO: This needs to be refactored to use the core setDate_new function. */
?>
<script language="javascript" type="text/javascript">
function setDate( frm_name, f_date ) {
fld_date = eval( 'document.' + frm_name + '.' + f_date );
fld_real_date = eval( 'document.' + frm_name + '.' + 'event_' + f_date );
if (fld_date.value.length>0) {
if ((parseDate(fld_date.value))==null) {
alert('The Date/Time you typed does not match your prefered format, please retype.');
fld_real_date.value = '';
fld_date.style.backgroundColor = 'red';
} else {
fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
fld_date.value = formatDate(parseDate(fld_date.value), '<?php
echo $cal_sdf;
?>
');
fld_date.style.backgroundColor = '';
}
} else {
fld_real_date.value = '';
}
}
function set_clash_action(action) {
document.editFrm.clash_action.value = action;
document.editFrm.submit();
}
</script>
<form name="editFrm" method="post" action="<?php
echo $calurl . '&clash_action=process';
?>
" accept-charset="utf-8">
<table width='100%' class='std addedit'>
<tr>
<td width='50%' align='right'><?php
echo $AppUI->_('Earliest Date');
?>
:</td>
<td width='50%' align='left' nowrap="nowrap">
<input type="hidden" name="event_start_date" id="event_start_date" value="<?php
echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : '';
?>
" />
<input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php
echo $start_date ? $start_date->format($df) : '';
?>
" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php
echo $df;
?>
', 'editFrm', null, true)">
<img src="<?php
echo w2PfindImage('calendar.gif');
?>
" width="24" height="12" alt="<?php
echo $AppUI->_('Calendar');
?>
" border="0" />
</a>
</td>
</tr>
<tr>
<td width='50%' align='right'><?php
echo $AppUI->_('Latest Date');
?>
:</td>
<td width='50%' align='left' nowrap="nowrap">
<input type="hidden" name="event_end_date" id="event_end_date" value="<?php
echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : '';
?>
" />
<input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php
echo $end_date ? $end_date->format($df) : '';
?>
//.........这里部分代码省略.........
示例5: 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;
}
示例6: hook_calendar
public function hook_calendar($userId)
{
$date = new w2p_Utilities_Date(w2PgetParam($_GET, 'date', null));
$date->setTime(0, 0, 0);
$start = $date->duplicate();
$end = $date->duplicate();
$view = w2PgetParam($_GET, 'a', 'month_view');
switch ($view) {
case 'day_view':
break;
case 'week_view':
$end->addDays(6);
break;
case 'index':
case 'month_view':
$start->setDay(1);
$end->setDay($date->getDaysInMonth());
break;
case 'year_view':
$start->setMonth(1);
$start->setDay(1);
$end->setMonth(12);
$end->setDay(31);
break;
}
$end->setTime(23, 59, 59);
$holidays = HolidayFunctions::getHolidaysForDatespan($start, $end, $userId);
$itemsList = array();
foreach ($holidays as $i => $holiday) {
$date = $holiday['startDate'];
$end = $holiday['endDate'];
while (!$date->after(clone $end)) {
$itemsList[] = array('id' => $holiday['id'], 'name' => $holiday['name'], 'startDate' => $date->format(FMT_TIMESTAMP_DATE), 'endDate' => $date->format(FMT_TIMESTAMP_DATE), 'description' => $holiday['description']);
$date = $date->getNextDay();
}
}
return $itemsList;
}
示例7: submitIt
$seldate->convertTZ('UTC');
$obj->event_start_date = $seldate->format(FMT_TIMESTAMP);
$seldate->convertTZ($AppUI->getPref('TIMEZONE'));
$seldate->setTime(w2PgetConfig('cal_day_end'), 0, 0);
$seldate->convertTZ('UTC');
$obj->event_end_date = $seldate->format(FMT_TIMESTAMP);
}
}
$start_date = intval($obj->event_start_date) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($obj->event_start_date, '%Y-%m-%d %T')) : null;
$end_date = intval($obj->event_end_date) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($obj->event_end_date, '%Y-%m-%d %T')) : $start_date;
$recurs = array('Never', 'Hourly', 'Daily', 'Weekly', 'Bi-Weekly', 'Every Month', 'Quarterly', 'Every 6 months', 'Every Year');
$remind = array('900' => '15 mins', '1800' => '30 mins', '3600' => '1 hour', '7200' => '2 hours', '14400' => '4 hours', '28800' => '8 hours', '56600' => '16 hours', '86400' => '1 day', '172800' => '2 days');
// build array of times in 30 minute increments
$times = array();
$t = new w2p_Utilities_Date();
$t->setTime(0, 0, 0);
//$m clashes with global $m (module)
for ($minutes = 0; $minutes < 24 * 60 / $inc; $minutes++) {
$times[$t->format('%H%M%S')] = $t->format($AppUI->getPref('TIMEFORMAT'));
$t->addSeconds($inc * 60);
}
?>
<script language="javascript" type="text/javascript">
function submitIt(){
var form = document.editFrm;
if (form.event_name.value.length < 1) {
alert('<?php
echo $AppUI->_('Please enter a valid event title', UI_OUTPUT_JS);
?>
');
form.event_name.focus();
示例8: testSetTimeInvalidSecond
/**
* Tests setTime with invalid second
*/
public function testSetTimeInvalidSecond()
{
$date = new w2p_Utilities_Date('2010-08-11 00:00:00');
$date->setTime(12, 12, 61);
$this->assertEquals('2010-08-11 12:12:00', $date->getDate(DATE_FORMAT_ISO));
}
示例9: array
if (!is_null($user_id)) {
$AppUI->setState('HolidaySelectedUser', $user_id);
} else {
$user_id = $AppUI->getState('HolidaySelectedUser') ? $AppUI->getState('HolidaySelectedUser') : $AppUI->user_id;
}
$is_my_holidays = $user_id == $AppUI->user_id;
// establish the focus 'date'
$date = w2PgetParam($_GET, 'date', null);
if (!$date) {
$date = new w2p_Utilities_Date();
} else {
$date = new w2p_Utilities_Date($date);
}
$date->setDay(1);
$date->setMonth(1);
$date->setTime(0, 0, 0);
$year = $date->getYear();
$prev_year = $date->format(FMT_TIMESTAMP_DATE);
$prev_year = (int) ($prev_year - 10000);
$next_year = $date->format(FMT_TIMESTAMP_DATE);
$next_year = (int) ($next_year + 10000);
$start = $date->duplicate();
$end = $date->duplicate();
$end->setMonth(12);
$end->setDay(31);
$end->setTime(23, 59, 59);
$holidays = array();
$holidaysList = HolidayFunctions::getDefaultCalendarHolidaysForDatespan($start, $end);
foreach ($holidaysList as $holiday) {
$id = 0;
$type = $holiday['type'];
示例10: CTask
$AppUI->holdObject($obj);
$AppUI->redirect('m=tasks&a=view&task_id=' . $obj->task_log_task);
}
if ($result) {
$AppUI->setMsg('Task Log ' . $action, UI_MSG_OK, true);
$task = new CTask();
$task->load($obj->task_log_task);
$canEditTask = $perms->checkModuleItem('tasks', 'edit', $task_id);
if ($canEditTask) {
$task->htmlDecode();
$task->check();
$task_end_date = new w2p_Utilities_Date($task->task_end_date);
$task->task_percent_complete = w2PgetParam($_POST, 'task_percent_complete', null);
if (w2PgetParam($_POST, 'task_end_date', '') != '') {
$new_date = new w2p_Utilities_Date($_POST['task_end_date']);
$new_date->setTime($task_end_date->hour, $task_end_date->minute, $task_end_date->second);
$task->task_end_date = $new_date->format(FMT_DATETIME_MYSQL);
}
if ($task->task_percent_complete >= 100 && (!$task->task_end_date || $task->task_end_date == '0000-00-00 00:00:00')) {
$task->task_end_date = $obj->task_log_date;
}
$msg = $task->store($AppUI);
if (is_array($msg)) {
$AppUI->setMsg($msg, UI_MSG_ERROR, true);
}
$new_task_end = new w2p_Utilities_Date($task->task_end_date);
if ($new_task_end->dateDiff($task_end_date)) {
$task->addReminder();
}
$task->pushDependencies($task->task_id, $task->task_end_date);
}