aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorGravatar Victor Huesca <victor.huesca@bootlin.com>2019-08-12 16:43:45 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-08-12 23:36:15 +0200
commit80d226f251a22f7c2edbaac01c97758fea040d1c (patch)
treea4c3c9d0c0eef0c301ab9cbe4ab8ce2f22c0d6dc /web
parentfa0e7ae0c23b4ed8cde7ef665295ee8aa972e71a (diff)
downloadbuildroot-test-80d226f251a22f7c2edbaac01c97758fea040d1c.tar.gz
buildroot-test-80d226f251a22f7c2edbaac01c97758fea040d1c.tar.bz2
web/index.php: reword the 'format_duration' function
The format_duration manually compute everything when it could just use the build-in date format function and trim the beginning for the same result. Signed-off-by: Victor Huesca <victor.huesca@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'web')
-rw-r--r--web/index.php22
1 files changed, 2 insertions, 20 deletions
diff --git a/web/index.php b/web/index.php
index f3af62d..939cac5 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,26 +1,8 @@
<?php
include("funcs.inc.php");
-function format_duration($seconds_count)
-{
- $delimiter = ':';
- $seconds = $seconds_count % 60;
- $minutes = floor($seconds_count/60) % 60;
- $hours = floor($seconds_count/3600);
-
- $seconds = str_pad($seconds, 2, "0", STR_PAD_LEFT);
- $minutes = str_pad($minutes, 2, "0", STR_PAD_LEFT).$delimiter;
-
- if($hours > 0)
- {
- $hours = str_pad($hours, 2, "0", STR_PAD_LEFT).$delimiter;
- }
- else
- {
- $hours = '';
- }
-
- return "$hours$minutes$seconds";
+function format_duration($seconds_count) {
+ return ltrim(gmdate('H:i:s', $seconds_count), '0:');
}
function format_url_args($args)