From 491a12276d99717648846009ba58d1ea088cee11 Mon Sep 17 00:00:00 2001 From: Grisu Date: Sun, 12 Jun 2022 22:40:38 +0200 Subject: [PATCH] fixed timestamp at the statistics table --- app/public/edit_statistics.php | 8 ++++++-- app/scripts/functions.php | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/public/edit_statistics.php b/app/public/edit_statistics.php index 58221ea..e8e4a98 100644 --- a/app/public/edit_statistics.php +++ b/app/public/edit_statistics.php @@ -21,7 +21,11 @@ } if (get_minutes($con, $m_id, $s_id)->fetch()['minutes'] != $minutes || get_seconds($con, $m_id, $s_id)->fetch()['seconds'] != $seconds || get_millis($con, $m_id, $s_id)->fetch()['millis'] != $millis) { - $time = "00:" . $minutes . ":" . $seconds . "." . $millis; + if ($millis < 10) { + $time = "00:" . $minutes . ":" . $seconds . "." . "0" . $millis; + } else { + $time = "00:" . $minutes . ":" . $seconds . "." . $millis; + } change_time($con, $m_id, $s_id, $time); } @@ -48,7 +52,7 @@ fetch()['seconds'] . "\""; }?>/>
- fetch()['millis'] . "\""; }?>/>
+ fetch()['millis'] / 1e4 . "\""; }?>/>
/> /> diff --git a/app/scripts/functions.php b/app/scripts/functions.php index 686f86f..5ad2bac 100644 --- a/app/scripts/functions.php +++ b/app/scripts/functions.php @@ -106,7 +106,12 @@ function load_station_table($con, $s_id) { echo "" . $row['Name'] . "\n"; echo "" . $row['Feuerwehr'] . "\n"; echo "" . $row['Punkte'] . "\n"; - echo "" . $row["Zeit"] . "\n"; + if ($row['Zeit'] != NULL) { + $time = get_time_str($con, $row['m_id'], $s_id); + echo "" . $time . "\n"; + } else { + echo "" . $row['Zeit'] . "\n"; + } echo "\n"; } echo "\n"; @@ -158,4 +163,30 @@ function check_time($con, $m_id, $s_id) { } else { return true; } +} + +function get_time_str($con, $m_id, $s_id) { + $minutes = get_minutes($con, $m_id, $s_id)->fetch()['minutes']; + $seconds = get_seconds($con, $m_id, $s_id)->fetch()['seconds']; + $millis = get_millis($con, $m_id, $s_id)->fetch()['millis']; + if ($minutes < 10) { + $time = "0" . $minutes; + } else { + $time = $minutes; + } + + if ($seconds < 10) { + $time .= ":0" . $seconds; + } else { + $time .= ":" . $seconds; + } + + $millis /= 10000; + + if ($millis < 10) { + $time .= ".0" . $millis; + } else { + $time .= "." . $millis; + } + return $time; } \ No newline at end of file