本文整理汇总了PHP中convert2days函数的典型用法代码示例。如果您正苦于以下问题:PHP convert2days函数的具体用法?PHP convert2days怎么用?PHP convert2days使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert2days函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConvert2days
public function testConvert2days()
{
$hours = 1;
$this->assertEquals(0.125, convert2days($hours, 0));
$hoursIndicator = 1;
$hours = 8;
$this->assertEquals(1, convert2days($hours, $hoursIndicator));
$dayIndicator = 24;
$days = 1;
$this->assertEquals(1, convert2days($days, $dayIndicator));
}
示例2: array
$orrarr[] = array('task_id' => 0, 'order_up' => 0, 'order' => '');
$end_max = '0000-00-00 00:00:00';
$start_min = date('Y-m-d H:i:s');
//pull the tasks into an array
foreach ($proTasks as $rec) {
if ($rec['task_start_date'] == '0000-00-00 00:00:00') {
$rec['task_start_date'] = date('Y-m-d H:i:s');
}
$tsd = new w2p_Utilities_Date($rec['task_start_date']);
if ($tsd->before(new w2p_Utilities_Date($start_min))) {
$start_min = $rec['task_start_date'];
}
// calculate or set blank task_end_date if unset
if ($rec['task_end_date'] == '0000-00-00 00:00:00') {
if ($rec['task_duration']) {
$rec['task_end_date'] = db_unix2dateTime(db_dateTime2unix($rec['task_start_date']) + SECONDS_PER_DAY * convert2days($rec['task_duration'], $rec['task_duration_type']));
} else {
$rec['task_end_date'] = '';
}
}
$ted = new w2p_Utilities_Date($rec['task_end_date']);
if ($ted->after(new w2p_Utilities_Date($end_max))) {
$end_max = $rec['task_end_date'];
}
$projects[$rec['task_project']]['tasks'][] = $rec;
}
$q->clear();
reset($projects);
foreach ($projects as $p) {
$tnums = count($p['tasks']);
for ($i = 0; $i < $tnums; $i++) {
示例3: CTask
$task = new CTask();
$task->setAllowedSQL($AppUI->user_id, $q);
$proTasks = $q->loadHashList('task_id');
$q->clear();
$orrarr[] = array('task_id' => 0, 'order_up' => 0, 'order' => '');
$end_max = '0000-00-00 00:00:00';
$start_min = date('Y-m-d H:i:s');
//pull the tasks into an array
$criticalTasks = $project->getCriticalTasks($project_id);
$actual_end_date = new CDate($criticalTasks[0]['task_end_date']);
$p_end_date = $actual_end_date->after($project->project_end_date) ? $criticalTasks[0]['task_end_date'] : $project->project_end_date;
foreach ($proTasks as $row) {
// calculate or set blank task_end_date if unset
if ($row['task_end_date'] == '0000-00-00 00:00:00') {
if ($row['task_duration'] && $row['task_start_date'] != '0000-00-00 00:00:00') {
$start_date_unix_time = db_dateTime2unix($row['task_start_date']) + SECONDS_PER_DAY * convert2days($row['task_duration'], $row['task_duration_type']);
$row['task_end_date'] = substr(db_unix2dateTime($start_date_unix_time), 1, -1);
} else {
$row['task_end_date'] = $p_end_date;
}
}
if ($row['task_start_date'] == '0000-00-00 00:00:00') {
$row['task_start_date'] = $project->project_start_date;
//date('Y-m-d H:i:s');
}
if ($row['task_start_date'] == '0000-00-00 00:00:00') {
$row['task_start_date'] = date(mktime(0, 0, 0, 1, 1, date('Y')), 'Y-m-d H:i:s');
}
$tsd = new CDate($row['task_start_date']);
if ($tsd->before(new CDate($start_min))) {
$start_min = $row['task_start_date'];
示例4: fixate_task
function fixate_task($task_index, $time, $dep_on_task)
{
// WARNING: task_index != task_id !!!
global $tasks, $do, $option_advance_if_possible, $AppUI, $df;
// don't fixate tasks before now
if ($time < time()) {
$time = time();
}
$start_date = $time;
$end_date = $start_date;
$durn = convert2days($tasks[$task_index]["task_duration"], $tasks[$task_index]["task_duration_type"]);
$end_date += $durn * SECONDS_PER_DAY;
// Complex SQL explanation:
//
// Objective: Check tasks overlapping only when
// a user is vital for both tasks
//
// Definition of "vital for one task": when a task is assigned to user and total_users <= 2
// (for example: if task is assigned to tree o more users, he is not vital).
//
// Thus, a user is vital for both tasks <=>
// - total_users <= 2 for both tasks
// - and he apears in both tasks
//
// Thus, in both tasks (say 4 and 10), a there will be a vital user <=>
// - "number of tasks with total_users <= 2"
// = rows("select count(*) as num_users from user_tasks
// where task_id=4 or task_id=10
// group by task_id having num_users <= 2") == 2;
//
// - and "number of users which appears in both tasks"
// = rows("select count(*) as frec
// from user_tasks where task_id=4 or task_id=10
// group by user_id having frec = 2") > 0
$t1_start = $start_date;
$t1_end = $end_date;
foreach ($tasks as $task2) {
$t2_start = db_dateTime2unix($task2["task_start_date"]);
$t2_end = db_dateTime2unix($task2["task_end_date"]);
if ($task2["fixed"] && ($t1_start >= $t2_start && $t1_start <= $t2_end || $t1_end >= $t2_start && $t1_end <= $t2_end)) {
// tasks are overlapping
if (!$option_advance_if_possible || $task2["task_percent_complete"] != 100) {
$t1 = $tasks[$task_index]["task_id"];
$t2 = $task2["task_id"];
if ($option_check_vital_users) {
$sql1 = "select count(*) as num_users from user_tasks where task_id={$t1} or task_id={$t2} group by task_id having num_users <= 2";
$sql2 = "select count(*) as frec from user_tasks where task_id={$t1} or task_id={$t2} group by user_id having frec = 2";
$vital = mysql_num_rows(mysql_query($sql1)) == 2 && mysql_num_rows(mysql_query($sql2)) > 0;
} else {
$vital = true;
}
if ($vital) {
log_info("Task can't be set to [" . formatTime($start_date) . " - " . formatTime($end_date) . "] due to conflicts with task " . task_link($task2) . ".");
// OBS: I'm asuming the dependent task will start next day
fixate_task($task_index, $t2_end + SECONDS_PER_DAY, $dep_on_task);
return;
} else {
log_info("Task conflicts with task " . task_link($task2) . " but there are no vital users.");
}
} else {
log_info("Task " . task_link($task2) . " is complete, I won't check if it is overllaping");
}
}
}
$tasks[$task_index]["fixed"] = true;
// be quite if nothing changes
if (db_dateTime2unix($tasks[$task_index]["task_start_date"]) == $start_date && db_dateTime2unix($tasks[$task_index]["task_end_date"]) == $end_date) {
log_info("Nothing changed, still programmed for [" . formatTime($start_date) . " - " . formatTime($end_date) . "]");
return;
}
$tasks[$task_index]["task_start_date"] = db_unix2dateTime($start_date);
$tasks[$task_index]["task_end_date"] = db_unix2dateTime($end_date);
if ($do == "ask") {
if ($dep_on_task) {
log_action("I will fixate task " . task_link($tasks[$task_index]) . " to " . formatTime($start_date) . " (depends on " . task_link($dep_on_task) . ")");
} else {
log_action("I will fixate task " . task_link($tasks[$task_index]) . " to " . formatTime($start_date) . " (no dependencies)");
}
// echo "<input type=hidden name=fixate_task[" . $tasks[$task_index]["task_id"] . "] value=y>";
} else {
if ($do == "fixate") {
log_action("Task " . task_link($tasks[$task_index]) . " fixated to " . formatTime($start_date));
$sql = "update tasks set task_start_date = '" . db_unix2dateTime($start_date) . "', task_end_date = '" . db_unix2dateTime($end_date) . "' where task_id = " . $tasks[$task_index]["task_id"];
mysql_query($sql);
}
}
}
示例5: db_exec
$tsql = "SELECT {$select} FROM {$from} {$join} WHERE {$where} ORDER BY project_id, task_start_date";
##echo "<pre>$tsql</pre>".mysql_error();##
$ptrc = db_exec($tsql);
$nums = db_num_rows($ptrc);
echo db_error();
$orrarr[] = array("task_id" => 0, "order_up" => 0, "order" => "");
//pull the tasks into an array
for ($x = 0; $x < $nums; $x++) {
$row = db_fetch_assoc($ptrc);
if ($row["task_start_date"] == "0000-00-00 00:00:00") {
$row["task_start_date"] = date("Y-m-d H:i:s");
}
// calculate or set blank task_end_date if unset
if ($row["task_end_date"] == "0000-00-00 00:00:00") {
if ($row["task_duration"]) {
$row["task_end_date"] = db_unix2dateTime(db_dateTime2unix($row["task_start_date"]) + SECONDS_PER_DAY * convert2days($row["task_duration"], $row["task_duration_type"]));
} else {
$row["task_end_date"] = "";
}
}
$projects[$row['task_project']]['tasks'][] = $row;
}
$width = dPgetParam($_GET, 'width', 600);
//consider critical (concerning end date) tasks as well
$project_end = $projects[$project_id]["project_end_date"] > $criticalTasks[0]['task_end_date'] ? $projects[$project_id]["project_end_date"] : $criticalTasks[0]['task_end_date'];
$start_date = dPgetParam($_GET, 'start_date', $projects[$project_id]["project_start_date"]);
$end_date = dPgetParam($_GET, 'end_date', $project_end);
$count = 0;
$graph = new GanttGraph($width);
$graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
//$graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY);