Kimai_Format::formatDuration PHP Method

formatDuration() public static method

Format a duration given in seconds according to the global setting. Either seconds are shown or not.
public static formatDuration ( $sek ) : integer | array
return integer | array depending on the $sek param which contains the formatted duration
    public static function formatDuration($sek)
    {
        global $kga;
        if (is_array($sek)) {
            // Convert all values of the array.
            $arr = array();
            foreach ($sek as $key => $value) {
                $arr[$key] = self::formatDuration($value);
            }
            return $arr;
        }
        // Format accordingly.
        if ($kga['conf']['durationWithSeconds'] == 0) {
            return sprintf('%d:%02d', $sek / 3600, $sek / 60 % 60);
        }
        return sprintf('%d:%02d:%02d', $sek / 3600, $sek / 60 % 60, $sek % 60);
    }

Usage Example

コード例 #1
0
ファイル: private_func.php プロジェクト: kimai/kimai
function invoice_add_to_array(&$array, $row, $short_form)
{
    global $activityIndexMap;
    if ($short_form && $row['type'] == 'timeSheet') {
        if (isset($activityIndexMap[$row['desc']])) {
            $index = $activityIndexMap[$row['desc']];
            $totalTime = $array[$index]['hour'];
            $totalAmount = $array[$index]['amount'];
            $start = $array[$index]['start'];
            $end = $array[$index]['end'];
            $duration = $array[$index]['duration'];
            $array[$index] = array('type' => 'timeSheet', 'desc' => $row['desc'], 'start' => $start < $row['start'] ? $start : $row['start'], 'end' => $end > $row['end'] ? $end : $row['end'], 'hour' => $totalTime + $row['hour'], 'fDuration' => Kimai_Format::formatDuration($duration + $row['duration']), 'duration' => $duration + $row['duration'], 'timestamp' => $start < $row['start'] ? $start : $row['start'], 'amount' => $totalAmount + $row['amount'], 'description' => $row['description'], 'rate' => ($totalAmount + $row['amount']) / ($totalTime + $row['hour']), 'comment' => $row['comment'], 'username' => $row['username'], 'useralias' => $row['useralias'], 'location' => $row['location'], 'trackingNr' => $row['trackingNr'], 'projectID' => $row['projectID'], 'projectName' => $row['projectName'], 'projectComment' => $row['projectComment'], 'date' => date("m/d/Y", $row['timestamp']));
            return;
        } else {
            $activityIndexMap[$row['desc']] = count($array);
        }
    }
    $array[] = $row;
}
All Usage Examples Of Kimai_Format::formatDuration