本文整理汇总了PHP中w2p_Utilities_Date::addDays方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::addDays方法的具体用法?PHP w2p_Utilities_Date::addDays怎么用?PHP w2p_Utilities_Date::addDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Utilities_Date
的用法示例。
在下文中一共展示了w2p_Utilities_Date::addDays方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
//Action: Modify Percent Complete
if ($bulk_task_percent_complete != '' && (int) $_POST['bulk_task_percent_complete'] == (int) $bulk_task_percent_complete) {
if ($upd_task->task_id) {
$upd_task->task_percent_complete = $bulk_task_percent_complete;
$result = $upd_task->store($AppUI);
if (is_array($result)) {
break;
}
}
}
//Action: Move Task Date
if (isset($_POST['bulk_move_date']) && $bulk_move_date != '' && $bulk_move_date) {
if ($upd_task->task_id && ((int) $upd_task->task_dynamic != 1 && !$upd_task->getDependencies($upd_task->task_id))) {
$offSet = $bulk_move_date;
$start_date = new w2p_Utilities_Date($upd_task->task_start_date);
$start_date->addDays($offSet);
$upd_task->task_start_date = $start_date->format(FMT_DATETIME_MYSQL);
$end_date = new w2p_Utilities_Date($upd_task->task_end_date);
$end_date->addDays($offSet);
$upd_task->task_end_date = $end_date->format(FMT_DATETIME_MYSQL);
$result = $upd_task->store($AppUI);
if (is_array($result)) {
break;
}
$upd_task->shiftDependentTasks();
}
}
//Action: Modify End Date
if (isset($_POST['add_task_bulk_end_date']) && $bulk_task_end_date != '' && $bulk_end_date) {
if ($upd_task->task_id) {
$upd_task->task_end_date = $bulk_end_date;
示例2: 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;
}
示例3: foreach
foreach ($res as $rw) {
switch ($rw['perc_assignment']) {
case 100:
$caption .= $rw['contact_display_name'] . ';';
break;
default:
$caption .= $rw['contact_display_name'] . ' [' . $rw['perc_assignment'] . '%];';
break;
}
}
$q->clear();
$caption = mb_substr($caption, 0, mb_strlen($caption) - 1);
}
if ($flags == 'm') {
$start = new w2p_Utilities_Date($start);
$start->addDays(0);
$s = $start->format($df);
if ($caller == 'todo') {
$gantt->addMilestone(array($name, $pname, '', $s, $s), $a['task_start_date']);
} else {
$gantt->addMilestone(array($name, '', $s, $s), $a['task_start_date']);
}
} else {
$type = $a['task_duration_type'];
$dur = $a['task_duration'];
if ($type == 24) {
$dur *= $w2Pconfig['daily_working_hours'];
}
if ($showWork == '1') {
$work_hours = 0;
$q = new w2p_Database_Query();
示例4: getRecurrentEventforPeriod
/**
* Calculating if an recurrent date is in the given period
* @param Date Start date of the period
* @param Date End date of the period
* @param Date Start date of the Date Object
* @param Date End date of the Date Object
* @param integer Type of Recurrence
* @param integer Times of Recurrence
* @param integer Time of Recurrence
* @return array Calculated Start and End Dates for the recurrent Event for the given Period
*/
public function getRecurrentEventforPeriod($start_date, $end_date, $event_start_date, $event_end_date, $event_recurs, $event_times_recuring, $j)
{
//this array will be returned
$transferredEvent = array();
//create Date Objects for Event Start and Event End
$eventStart = new w2p_Utilities_Date($event_start_date);
$eventEnd = new w2p_Utilities_Date($event_end_date);
//Time of Recurence = 0 (first occurence of event) has to be checked, too.
if ($j > 0) {
switch ($event_recurs) {
case 1:
$eventStart->addSpan(new Date_Span(3600 * $j));
$eventEnd->addSpan(new Date_Span(3600 * $j));
break;
case 2:
$eventStart->addDays($j);
$eventEnd->addDays($j);
break;
case 3:
$eventStart->addDays(7 * $j);
$eventEnd->addDays(7 * $j);
break;
case 4:
$eventStart->addDays(14 * $j);
$eventEnd->addDays(14 * $j);
break;
case 5:
$eventStart->addMonths($j);
$eventEnd->addMonths($j);
break;
case 6:
$eventStart->addMonths(3 * $j);
$eventEnd->addMonths(3 * $j);
break;
case 7:
$eventStart->addMonths(6 * $j);
$eventEnd->addMonths(6 * $j);
break;
case 8:
$eventStart->addMonths(12 * $j);
$eventEnd->addMonths(12 * $j);
break;
default:
break;
}
}
if ($start_date->compare($start_date, $eventStart) <= 0 && $end_date->compare($end_date, $eventEnd) >= 0) {
// add temporarily moved Event Start and End dates to returnArray
$transferredEvent = array($eventStart, $eventEnd);
}
// return array with event start and end dates for given period (positive case)
// or an empty array (negative case)
return $transferredEvent;
}
示例5: render
public function render($markToday = true, $filename = '')
{
if ($markToday) {
$today = new w2p_Utilities_Date();
$today->convertTZ($this->AppUI->getPref('TIMEZONE'));
$today->addDays(-1);
$vline = new GanttVLine($today->format(FMT_DATETIME_MYSQL), $this->todayText);
$vline->title->setFont(FF_CUSTOM, FS_NORMAL, 8);
$this->graph->Add($vline);
}
$filename == '' ? $this->graph->Stroke() : $this->graph->Stroke($filename);
}
示例6: importTasks
/**
* Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
*
* @todo - this entire thing has nothing to do with projects.. it should move to the CTask class - dkc 25 Nov 2012
* @todo - why are we returning either an array or a boolean? You make my head hurt. - dkc 25 Nov 2012
*
* @todo - we should decide if we want to include the contacts associated with each task
* @todo - we should decide if we want to include the files associated with each task
* @todo - we should decide if we want to include the links associated with each task
*
* Of the three - contacts, files, and links - I can see a case made for
* all three. Imagine you have a task which requires a particular form to
* be filled out (Files) but there's also documentation you need about it
* (Links) and once the task is underway, you need to let some people
* know (Contacts). - dkc 25 Nov 2012
* */
public function importTasks($from_project_id, $to_project_id, $project_start_date)
{
$errors = array();
$old_new_task_mapping = array();
$old_dependencies = array();
$old_parents = array();
$project_start_date = new w2p_Utilities_Date($project_start_date);
$newTask = new w2p_Actions_BulkTasks();
$task_list = $newTask->loadAll('task_start_date', "task_represents_project = 0 AND task_project = " . $from_project_id);
$first_task = array_shift($task_list);
/**
* This gets the first (earliest) task start date and figures out
* how much we have to shift all the tasks by.
*/
$original_start_date = new w2p_Utilities_Date($first_task['task_start_date']);
$timeOffset = $original_start_date->dateDiff($project_start_date);
array_unshift($task_list, $first_task);
foreach ($task_list as $orig_task) {
$orig_id = $orig_task['task_id'];
$new_start_date = new w2p_Utilities_Date($orig_task['task_start_date']);
$new_start_date->addDays($timeOffset);
$new_end_date = new w2p_Utilities_Date($orig_task['task_end_date']);
$new_end_date->addDays($timeOffset);
$old_parents[$orig_id] = $orig_task['task_parent'];
$orig_task['task_id'] = 0;
$orig_task['task_parent'] = 0;
$orig_task['task_project'] = $to_project_id;
$orig_task['task_sequence'] = 0;
$orig_task['task_path_enumeration'] = '';
$orig_task['task_hours_worked'] = 0;
// This is necessary because we're using bind() and it shifts by timezone
$orig_task['task_start_date'] = $this->_AppUI->formatTZAwareTime($new_start_date->format(FMT_DATETIME_MYSQL), '%Y-%m-%d %T');
$orig_task['task_end_date'] = $this->_AppUI->formatTZAwareTime($new_end_date->format(FMT_DATETIME_MYSQL), '%Y-%m-%d %T');
$_newTask = new w2p_Actions_BulkTasks();
$_newTask->bind($orig_task);
$_newTask->store();
$task_map[$orig_id] = $_newTask->task_id;
$old_dependencies[$orig_id] = array_keys($_newTask->getDependentTaskList($orig_id));
$old_new_task_mapping[$orig_id] = $_newTask->task_id;
}
if (count($errors)) {
$this->_error = $errors;
foreach ($old_new_task_mapping as $new_id) {
$newTask->task_id = $new_id;
$newTask->delete();
}
} else {
$q = $this->_getQuery();
/* This makes sure we have all the dependencies mapped out. */
foreach ($old_dependencies as $from => $to_array) {
foreach ($to_array as $to) {
$q->addTable('task_dependencies');
$q->addInsert('dependencies_req_task_id', $old_new_task_mapping[$from]);
$q->addInsert('dependencies_task_id', $old_new_task_mapping[$to]);
$q->exec();
$q->clear();
}
}
/* This makes sure all the parents are connected properly. */
foreach ($old_parents as $old_child => $old_parent) {
if ($old_child == $old_parent) {
/** Remember, this means skip the rest of the loop. */
continue;
}
$q->addTable('tasks');
$q->addUpdate('task_parent', $old_new_task_mapping[$old_parent]);
$q->addWhere('task_id = ' . $old_new_task_mapping[$old_child]);
$q->exec();
$q->clear();
}
/* This copies the task assigness to the new tasks. */
foreach ($old_new_task_mapping as $old_id => $new_id) {
$newTask->task_id = $old_id;
$newTask->copyAssignedUsers($new_id);
}
}
$_task = new CTask();
$task_list = $_task->loadAll('task_parent, task_id', "task_project = " . $to_project_id);
foreach ($task_list as $key => $data) {
$_task->load($key);
$_task->_updatePathEnumeration();
//.........这里部分代码省略.........
示例7: testAddDaysAcrossYear
/**
* Tests addDays function when the days being added spans the end of a year
*/
public function testAddDaysAcrossYear()
{
$date = new w2p_Utilities_Date('2010-12-31 00:00:00');
$date->addDays(2);
$this->assertEquals('2011-01-02 00:00:00', $date->getDate(DATE_FORMAT_ISO));
}
示例8: die
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
// @todo convert to template
// @todo remove database query
global $AppUI, $w2Pconfig, $cal_df, $cf;
// check permissions for this module
$perms =& $AppUI->acl();
$canView = canView($m);
$canAddProjects = $perms->checkModuleItem('projects', 'add');
if (!$canView) {
$AppUI->redirect(ACCESS_DENIED);
}
$AppUI->getTheme()->loadCalendarJS();
$today = new w2p_Utilities_Date();
$today->addDays(1);
$today->setHour($w2Pconfig['cal_day_start']);
$today->setMinute(0);
$view_options = __extract_from_projectdesigner1($AppUI);
$project_id = (int) w2PgetParam($_POST, 'project_id', 0);
$project_id = (int) w2PgetParam($_GET, 'project_id', $project_id);
$extra = array('where' => 'project_active = 1');
$project = new CProject();
$projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$idx_companies = __extract_from_projectdesigner2();
foreach ($projects as $prj_id => $prj_name) {
$projects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name;
}
asort($projects);
$projects = arrayMerge(array('0' => $AppUI->_('(None)', UI_OUTPUT_RAW)), $projects);
$extra = array();