From 9440903626ad042162c9364eb9d38a716b1d700e Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 28 Dec 2023 12:28:18 +0100 Subject: [PATCH] Using standard lib ght.php, which is more flexible --- web/lib/ght.php | 57 +++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/web/lib/ght.php b/web/lib/ght.php index a6fc0c3..32844ab 100644 --- a/web/lib/ght.php +++ b/web/lib/ght.php @@ -1,39 +1,50 @@ 0) + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; + $ts=$ts-$x*31536000; + $i+=2; +// weeks + $x=floor($ts/604800); + if ($x>0) + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; + $ts=$ts-$x*604800; + $i+=2; +// days $x=floor($ts/86400); if ($x>0) - ($x==1) ? $out[]=$x.$suffa[0][0] : $out[]=$x.$suffa[0][1]; + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; $ts=$ts-$x*86400; -//ore + $i+=2; +// hours $x=floor($ts/3600); if ($x>0) - ($x==1) ? $out[]=$x.$suffa[1][0] : $out[]=$x.$suffa[1][1]; + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; $ts=$ts-$x*3600; -//minuti + $i+=2; +// minutes $x=floor($ts/60); if ($x>0) - ($x==1) ? $out[]=$x.$suffa[2][0] : $out[]=$x.$suffa[2][1]; + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; $ts=$ts-$x*60; -//secondi - $x=round($ts,$ddn); - if ($x>0) - ($x==1) ? $out[]=$x.$suffa[3][0] : $out[]=$x.$suffa[3][1]; - $out=implode(', ',$out); - return($out); + $i+=2; +// seconds + $x=round($ts,$sd); + ($x==1) ? $out.=$x.$fa[$i] : $out.=$x.$fa[$i+1]; + return $out; } ?>