4 times "elseif" is not the way
and precalc. value sometimes help if well commentent
This commit is contained in:
parent
cb9b4db73d
commit
c7351dff09
@ -679,36 +679,38 @@ function listBoards($just_uri = false) {
|
|||||||
|
|
||||||
function until($timestamp) {
|
function until($timestamp) {
|
||||||
$difference = $timestamp - time();
|
$difference = $timestamp - time();
|
||||||
if ($difference < 60) {
|
switch(TRUE){
|
||||||
|
case ($difference < 60):
|
||||||
return $difference . ' ' . ngettext('second', 'seconds', $difference);
|
return $difference . ' ' . ngettext('second', 'seconds', $difference);
|
||||||
} elseif ($difference < 60*60) {
|
case ($difference < 3600): //60*60 = 3600
|
||||||
return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num);
|
return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num);
|
||||||
} elseif ($difference < 60*60*24) {
|
case ($difference < 86400): //60*60*24 = 86400
|
||||||
return ($num = round($difference/(60*60))) . ' ' . ngettext('hour', 'hours', $num);
|
return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num);
|
||||||
} elseif ($difference < 60*60*24*7) {
|
case ($difference < 604800): //60*60*24*7 = 604800
|
||||||
return ($num = round($difference/(60*60*24))) . ' ' . ngettext('day', 'days', $num);
|
return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num);
|
||||||
} elseif ($difference < 60*60*24*365) {
|
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||||
return ($num = round($difference/(60*60*24*7))) . ' ' . ngettext('week', 'weeks', $num);
|
return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num);
|
||||||
|
default:
|
||||||
|
return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($num = round($difference/(60*60*24*365))) . ' ' . ngettext('year', 'years', $num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ago($timestamp) {
|
function ago($timestamp) {
|
||||||
$difference = time() - $timestamp;
|
$difference = time() - $timestamp;
|
||||||
if ($difference < 60) {
|
switch(TRUE){
|
||||||
|
case ($difference < 60) :
|
||||||
return $difference . ' ' . ngettext('second', 'seconds', $difference);
|
return $difference . ' ' . ngettext('second', 'seconds', $difference);
|
||||||
} elseif ($difference < 60*60) {
|
case ($difference < 3600): //60*60 = 3600
|
||||||
return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num);
|
return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num);
|
||||||
} elseif ($difference < 60*60*24) {
|
case ($difference < 86400): //60*60*24 = 86400
|
||||||
return ($num = round($difference/(60*60))) . ' ' . ngettext('hour', 'hours', $num);
|
return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num);
|
||||||
} elseif ($difference < 60*60*24*7) {
|
case ($difference < 604800): //60*60*24*7 = 604800
|
||||||
return ($num = round($difference/(60*60*24))) . ' ' . ngettext('day', 'days', $num);
|
return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num);
|
||||||
} elseif ($difference < 60*60*24*365) {
|
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||||
return ($num = round($difference/(60*60*24*7))) . ' ' . ngettext('week', 'weeks', $num);
|
return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num);
|
||||||
|
default:
|
||||||
|
return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($num = round($difference/(60*60*24*365))) . ' ' . ngettext('year', 'years', $num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayBan($ban) {
|
function displayBan($ban) {
|
||||||
|
Loading…
Reference in New Issue
Block a user