当前位置: 首页>>代码示例>>PHP>>正文


PHP w2p_Utilities_Date::addDuration方法代码示例

本文整理汇总了PHP中w2p_Utilities_Date::addDuration方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Utilities_Date::addDuration方法的具体用法?PHP w2p_Utilities_Date::addDuration怎么用?PHP w2p_Utilities_Date::addDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在w2p_Utilities_Date的用法示例。


在下文中一共展示了w2p_Utilities_Date::addDuration方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_dep_dates

 public function update_dep_dates($task_id)
 {
     $q = new w2p_Database_Query();
     $newTask = new CTask();
     $newTask->load($task_id);
     // Do not update tasks that are not tracking dependencies
     if (!in_array($newTask->task_dynamic, self::$tracking_dynamics)) {
         return;
     }
     // load original task dates and calculate task time span
     $tsd = new w2p_Utilities_Date($newTask->task_start_date);
     $ted = new w2p_Utilities_Date($newTask->task_end_date);
     $duration = $tsd->calcDuration($ted);
     // reset start date
     $nsd = new w2p_Utilities_Date($newTask->get_deps_max_end_date($newTask));
     // prefer Wed 8:00 over Tue 16:00 as start date
     $nsd = $nsd->next_working_day();
     $new_start_date = $nsd->format(FMT_DATETIME_MYSQL);
     // Add task time span to End Date again
     $ned = new w2p_Utilities_Date();
     $ned->copy($nsd);
     $ned->addDuration($duration, '1');
     // make sure one didn't land on a non-working day
     $ned = $ned->next_working_day(true);
     // prefer tue 16:00 over wed 8:00 as an end date
     $ned = $ned->prev_working_day();
     $new_end_date = $ned->format(FMT_DATETIME_MYSQL);
     // update the db
     $q->addTable('tasks');
     $q->addUpdate('task_start_date', $new_start_date);
     $q->addUpdate('task_end_date', $new_end_date);
     $q->addUpdate('task_updated', "'" . $q->dbfnNowWithTZ() . "'", false, true);
     $q->addWhere('task_dynamic <> 1 AND task_id = ' . (int) $task_id);
     $q->exec();
     $q->clear();
     if ($newTask->task_parent != $newTask->task_id) {
         $newTask->updateDynamics();
     }
     return;
 }
开发者ID:eureka2,项目名称:web2project,代码行数:40,代码来源:tasks.class.php

示例2: array

 }
 // This call has to be here to make sure that old dependencies are
 // cleared on save, even if there's no new dependencies
 $obj->updateDependencies($hdependencies, $obj->task_id);
 if (isset($hdependencies) && '' != $hdependencies) {
     // there are dependencies set!
     $nsd = new w2p_Utilities_Date($obj->get_deps_max_end_date($obj));
     if (isset($start_date)) {
         $shift = $nsd->compare($start_date, $nsd);
         if ($shift < 1) {
             //$obj->task_start_date = $nsd->format(FMT_DATETIME_MYSQL);
             $osd = new w2p_Utilities_Date($obj->task_start_date);
             $ned = new w2p_Utilities_Date($obj->task_end_date);
             $dur = -$ned->calcDuration($osd);
             $ned->copy($nsd);
             $ned->addDuration($dur, 1);
             $new_start_date = $nsd->format(FMT_DATETIME_MYSQL);
             $obj->task_start_date = $AppUI->formatTZAwareTime($new_start_date, '%Y-%m-%d %T');
             $new_end_date = $ned->format(FMT_DATETIME_MYSQL);
             $obj->task_end_date = $AppUI->formatTZAwareTime($new_end_date, '%Y-%m-%d %T');
             $obj->store();
         }
     }
 }
 $obj->updateDynamics();
 $billingCategory = w2PgetSysVal('BudgetCategory');
 $budgets = array();
 foreach ($billingCategory as $id => $category) {
     $budgets[$id] = w2PgetParam($_POST, 'budget_' . $id, 0);
 }
 $obj->storeBudget($budgets);
开发者ID:illuminate3,项目名称:web2project,代码行数:31,代码来源:do_task_aed.php

示例3: executePost


//.........这里部分代码省略.........
         } elseif ($tmp[0] != '') {
             $hperc_assign_ar[$tmp[0]] = 100;
         }
     }
     // let's check if there are some assigned departments to task
     $task->task_departments = implode(',', $this->getParam('dept_ids', self::TYPE_ARRAY));
     // convert dates to SQL format first
     if ($task->task_start_date) {
         $date = new w2p_Utilities_Date($task->task_start_date);
         $task->task_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     $end_date = null;
     if ($task->task_end_date) {
         if (strpos($task->task_end_date, '2400') !== false) {
             $task->task_end_date = str_replace('2400', '2359', $task->task_end_date);
         }
         $end_date = new w2p_Utilities_Date($task->task_end_date);
         $task->task_end_date = $end_date->format(FMT_DATETIME_MYSQL);
     }
     $error_array = $task->store($AppUI);
     // Return all the validation messages
     if ($error_array !== true) {
         $error_message = '';
         foreach ($error_array as $error) {
             $error_message .= $error . '. ';
         }
         throw new Frapi_Error('SAVE_ERROR', $error_message);
     }
     $task_parent = $this->getParam('task_parent') ? $this->getParam('task_parent', SELF::TYPE_INT) : 0;
     $old_task_parent = $this->getParam('old_task_parent') ? $this->getParam('old_task_parent', SELF::TYPE_INT) : 0;
     if ($task_parent != $old_task_parent) {
         $oldTask = new CTask();
         $oldTask->load($old_task_parent);
         $oldTask->updateDynamics(false);
     }
     // How to handle custom fields? Do we support it in api?
     // Now add any task reminders
     // If there wasn't a task, but there is one now, and
     // that task date is set, we need to set a reminder.
     if (empty($task_end_date) || !empty($end_date) && $task_end_date->dateDiff($end_date)) {
         $task->addReminder();
     }
     if (isset($hassign)) {
         $task->updateAssigned($hassign, $hperc_assign_ar);
     }
     if (isset($hdependencies)) {
         // && !empty($hdependencies)) {
         // there are dependencies set!
         // backup initial start and end dates
         $tsd = new w2p_Utilities_Date($task->task_start_date);
         $ted = new w2p_Utilities_Date($task->task_end_date);
         // updating the table recording the
         // dependency relations with this task
         $task->updateDependencies($hdependencies, $task_parent);
         // we will reset the task's start date based upon dependencies
         // and shift the end date appropriately
         if ($adjustStartDate && !is_null($hdependencies)) {
             // load already stored task data for this task
             $tempTask = new CTask();
             $tempTask->load($task->task_id);
             // shift new start date to the last dependency end date
             $nsd = new w2p_Utilities_Date($tempTask->get_deps_max_end_date($tempTask));
             // prefer Wed 8:00 over Tue 16:00 as start date
             $nsd = $nsd->next_working_day();
             // prepare the creation of the end date
             $ned = new w2p_Utilities_Date();
             $ned->copy($nsd);
             if (empty($task->task_start_date)) {
                 // appropriately calculated end date via start+duration
                 $ned->addDuration($task->task_duration, $task->task_duration_type);
             } else {
                 // calc task time span start - end
                 $d = $tsd->calcDuration($ted);
                 // Re-add (keep) task time span for end date.
                 // This is independent from $obj->task_duration.
                 // The value returned by Date::Duration() is always in hours ('1')
                 $ned->addDuration($d, '1');
             }
             // prefer tue 16:00 over wed 8:00 as an end date
             $ned = $ned->prev_working_day();
             $task->task_start_date = $nsd->format(FMT_DATETIME_MYSQL);
             $task->task_end_date = $ned->format(FMT_DATETIME_MYSQL);
             $q = new w2p_Database_Query();
             $q->addTable('tasks', 't');
             $q->addUpdate('task_start_date', $task->task_start_date);
             $q->addUpdate('task_end_date', $task->task_end_date);
             $q->addWhere('task_id = ' . (int) $task->task_id);
             $q->addWhere('task_dynamic <> 1');
             $q->exec();
             $q->clear();
         }
         $task->pushDependencies($task->task_id, $task->task_end_date);
     }
     //$task = (array)$task;
     $task->load($task_id);
     unset($task->_query, $task->_error, $task->_tbl_prefix, $task->_tbl, $task->_tbl_key, $task->_tbl_module);
     $this->data['task'] = $task;
     $this->data['success'] = true;
     return $this->toArray();
 }
开发者ID:robertbasic,项目名称:web2project-api,代码行数:101,代码来源:Task.php

示例4: __extract_from_projects_gantt4

/**
 * Check if end date exists, if not try giving it the start date. If the start date does not exist then set it for
 *   today. This avoids jpgraphs internal errors that render the gantt completely useless
 *
 * @param $row
 * @return array
 */
function __extract_from_projects_gantt4($row)
{
    if ($row['task_end_date'] == '0000-00-00 00:00:00') {
        if ($row['task_duration']) {
            $date = new w2p_Utilities_Date($row['task_start_date']);
            $date->addDuration($row['task_duration'], $row['task_duration_type']);
        } else {
            $date = new w2p_Utilities_Date();
        }
        $row['task_end_date'] = $date->format(FMT_TIMESTAMP_DATE);
    }
    return $row['task_end_date'];
}
开发者ID:illuminate3,项目名称:web2project,代码行数:20,代码来源:cleanup_functions.php

示例5: pushDependencies

 /**
  * This function is run immediately after a Task is stored. It uses that Task's
  *    end date and checks for dependent tasks beginning before that date.
  * If there are any dependencies that match those criteria, it updates those
  *    and recurses.
  * If not, it returns.
  *
  * @param type $task_id
  * @param type $lastEndDate
  */
 public function pushDependencies($task_id, $lastEndDate)
 {
     $task_end_int = strtotime($lastEndDate);
     $dependent_tasks = $this->getDependentTaskList($task_id);
     foreach ($dependent_tasks as $_task_id => $_task_data) {
         $task_start_int = strtotime($_task_data['task_start_date']);
         if ($task_start_int >= $task_end_int) {
             /**
              * Remember, this continue just means 'skip this iteration and
              *   go to the next one.' In this case, we're skipping the
              *   iteration because either the dependent task's start date is
              *   already at or after the end date we have.
              */
             continue;
         }
         $nsd = new w2p_Utilities_Date($lastEndDate);
         $osd = new w2p_Utilities_Date($_task_data['task_start_date']);
         $ned = new w2p_Utilities_Date($_task_data['task_end_date']);
         $dur = -$ned->calcDuration($osd);
         $ned->copy($nsd);
         $ned->addDuration($dur, 1);
         $new_start_date = $nsd->format(FMT_DATETIME_MYSQL);
         $new_end_date = $ned->format(FMT_DATETIME_MYSQL);
         $q = $this->_getQuery();
         $q->addTable('tasks');
         $q->addUpdate('task_start_date', $new_start_date);
         $q->addUpdate('task_end_date', $new_end_date);
         $q->addUpdate('task_updated', "'" . $q->dbfnNowWithTZ() . "'", false, true);
         $q->addWhere('task_dynamic > 1 AND task_id = ' . (int) $_task_id);
         $q->exec();
         $this->pushDependencies($_task_id, $new_end_date);
     }
 }
开发者ID:victorrod,项目名称:web2project,代码行数:43,代码来源:tasks.class.php

示例6: testAddDurationInvalidDurationType

 /**
  * Tests addDuration with an invalid duration type (valid are 1(hours), or
  * 24(days))
  */
 public function testAddDurationInvalidDurationType()
 {
     $date = new w2p_Utilities_Date('2010-08-30 10:00:00');
     $date->addDuration(1, 17);
     $this->assertEquals('2010-08-30 10:00:00', $date->getDate(DATE_FORMAT_ISO));
 }
开发者ID:eureka2,项目名称:web2project,代码行数:10,代码来源:date.test.php

示例7: foreach

 foreach ($updateFields as $name => $value) {
     if ($value != '' && (int) $_POST[$name] == (int) $value) {
         if ($upd_task->task_id) {
             $upd_task->{str_replace('bulk_', '', $name)} = $value;
             $result = $upd_task->store();
             if (!$result) {
                 break;
             }
         }
     }
 }
 //Action: Bulk Move Tasks
 if ($bulk_move_date) {
     $start_date = new w2p_Utilities_Date($upd_task->task_start_date);
     $end_date = new w2p_Utilities_Date($upd_task->task_end_date);
     $start_date->addDuration($bulk_move_date, 24);
     $upd_task->task_start_date = $start_date->format(FMT_DATETIME_MYSQL);
     $end_date->addDuration($bulk_move_date, 24);
     $upd_task->task_end_date = $end_date->format(FMT_DATETIME_MYSQL);
     $result = $upd_task->store();
 }
 //Action: Move Task Date
 if ($bulk_task_start_date || $bulk_task_end_date) {
     $start_date_old = new w2p_Utilities_Date($upd_task->task_start_date);
     $end_date_old = new w2p_Utilities_Date($upd_task->task_end_date);
     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());
开发者ID:illuminate3,项目名称:web2project,代码行数:31,代码来源:do_task_bulk_aed.php

示例8: CTask

 // we will reset the task's start date based upon dependencies
 // and shift the end date appropriately
 if ($adjustStartDate && !is_null($hdependencies)) {
     // load already stored task data for this task
     $tempTask = new CTask();
     $tempTask->load($obj->task_id);
     // shift new start date to the last dependency end date
     $nsd = new w2p_Utilities_Date($tempTask->get_deps_max_end_date($tempTask));
     // prefer Wed 8:00 over Tue 16:00 as start date
     $nsd = $nsd->next_working_day();
     // prepare the creation of the end date
     $ned = new w2p_Utilities_Date();
     $ned->copy($nsd);
     if (empty($obj->task_start_date)) {
         // appropriately calculated end date via start+duration
         $ned->addDuration($obj->task_duration, $obj->task_duration_type);
     } else {
         // calc task time span start - end
         //$d = $tsd->calcDuration($ted);
         $d = $obj->task_duration;
         // Re-add (keep) task time span for end date.
         // This is independent from $obj->task_duration.
         // The value returned by Date::Duration() is always in hours ('1')
         $ned->addDuration($d, '1');
     }
     // prefer tue 16:00 over wed 8:00 as an end date
     $ned = $ned->prev_working_day();
     $obj->task_start_date = $nsd->format(FMT_DATETIME_MYSQL);
     $obj->task_end_date = $ned->format(FMT_DATETIME_MYSQL);
     $obj->task_start_date = $AppUI->convertToSystemTZ($obj->task_start_date);
     $obj->task_end_date = $AppUI->convertToSystemTZ($obj->task_end_date);
开发者ID:viniciusbudines,项目名称:sisnuss,代码行数:31,代码来源:do_task_aed.php


注:本文中的w2p_Utilities_Date::addDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。