Example #1
0
foreach ($day_tasks as $task) {
    $class = '';
    $from = strtotime($task['from_time']);
    $to = strtotime($task['to_time']);
    if (date('Y-m-d', $from) != $day) {
        //Some tasks may start the day before.
        $from = strtotime("{$day} 00:00:00");
        //Set the starting point as today midnight.
    }
    if ($task['to_time'] == '0000-00-00 00:00:00') {
        //Active Task.
        $class .= 'active ';
        $to = time();
    }
    $left = getTimePercentage($from);
    $width = time2percent(0, ($to - $from) / 60);
    list($hour_difference, $minute_difference) = getTimeDifference($from, $to);
    if ($minute_difference < 3 and $hour_difference == 0) {
        continue;
    }
    //Too small as task to list(or its a accidental click)
    $from_time = date('h:i a', $from);
    $to_time = date('h:i a', $to);
    if ($width < 4) {
        $class .= 'small ';
    }
    $todays_tasks[] = array('class' => $class, 'left' => $left, 'width' => $width, 'name' => $task['name'], 'from_time' => $from_time, 'to_time' => $to_time, 'hour_difference' => $hour_difference, 'minute_difference' => $minute_difference);
    // Find the total time taken for each task.
    $task_id = $task['id'];
    if (!isset($tasks_aggregate[$task_id])) {
        //Initalize the array if its not created before
Example #2
0
function getTimePercentage($time)
{
    $hour = date('G', $time);
    $min = intval(date('i', $time));
    return time2percent($hour, $min);
}