initial commit
This commit is contained in:
commit
1cc4bf3572
254 changed files with 63622 additions and 0 deletions
htdocs/includes
41
htdocs/includes/helpers.inc.php
Normal file
41
htdocs/includes/helpers.inc.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
function sec2hms($seconds) {
|
||||
if ($seconds == 0)
|
||||
return '0 seconds';
|
||||
|
||||
$hours = floor($seconds / 3600);
|
||||
$seconds = $seconds % 3600;
|
||||
if ($hours > 0)
|
||||
$hstr = $hours . ($hours > 1 ? ' hours' : ' hour');
|
||||
else
|
||||
$hstr = false;
|
||||
|
||||
if ($seconds > 0) {
|
||||
$minutes = floor($seconds / 60);
|
||||
$seconds = $seconds % 60;
|
||||
if ($minutes > 0)
|
||||
$mstr .= $minutes . ($minutes > 1 ? ' minutes' : ' minute');
|
||||
else
|
||||
$mstr = false;
|
||||
|
||||
if ($seconds > 0)
|
||||
$sstr .= $seconds . ($seconds > 1 ? ' seconds' : ' second');
|
||||
else
|
||||
$sstr = false;
|
||||
} else {
|
||||
$mstr = false;
|
||||
$sstr = false;
|
||||
}
|
||||
|
||||
if ($hstr and $mstr and $sstr)
|
||||
return $hstr . ', ' . $mstr . ' and ' . $sstr;
|
||||
elseif ($hstr and $mstr)
|
||||
return $hstr . ' and ' . $mstr;
|
||||
elseif ($hstr and $sstr)
|
||||
return $hstr . ' and ' . $sstr;
|
||||
elseif ($mstr and $sstr)
|
||||
return $mstr . ' and ' . $sstr;
|
||||
else
|
||||
return $hstr . $mstr . $sstr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue