fixed timestamp at the statistics table

This commit is contained in:
2022-06-12 22:40:38 +02:00
parent 4118f76f92
commit 491a12276d
2 changed files with 38 additions and 3 deletions

View File

@@ -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) { 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) {
if ($millis < 10) {
$time = "00:" . $minutes . ":" . $seconds . "." . "0" . $millis;
} else {
$time = "00:" . $minutes . ":" . $seconds . "." . $millis; $time = "00:" . $minutes . ":" . $seconds . "." . $millis;
}
change_time($con, $m_id, $s_id, $time); change_time($con, $m_id, $s_id, $time);
} }
@@ -48,7 +52,7 @@
<label for="seconds">Sekunden</label> <label for="seconds">Sekunden</label>
<input name="seconds" type="number" min="0" max="60" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_seconds($con, $row['m_id'], $row['s_id'])->fetch()['seconds'] . "\""; }?>/><br> <input name="seconds" type="number" min="0" max="60" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_seconds($con, $row['m_id'], $row['s_id'])->fetch()['seconds'] . "\""; }?>/><br>
<label for="millis">Millisekunden</label> <label for="millis">Millisekunden</label>
<input name="millis" type="number" min="0" max="99" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_millis($con, $row['m_id'], $row['s_id'])->fetch()['millis'] . "\""; }?>/><br> <input name="millis" type="number" min="0" max="99" value=<?php if(!$time_set){echo"\"0\"";} else { echo "\"" . get_millis($con, $row['m_id'], $row['s_id'])->fetch()['millis'] / 1e4 . "\""; }?>/><br>
</div> </div>
<input type="hidden" name="m_id" value=<?php echo $row['m_id'] ?>/> <input type="hidden" name="m_id" value=<?php echo $row['m_id'] ?>/>
<input type="hidden" name="s_id" value=<?php echo $row['s_id'] ?>/> <input type="hidden" name="s_id" value=<?php echo $row['s_id'] ?>/>

View File

@@ -106,7 +106,12 @@ function load_station_table($con, $s_id) {
echo "<td>" . $row['Name'] . "</td>\n"; echo "<td>" . $row['Name'] . "</td>\n";
echo "<td>" . $row['Feuerwehr'] . "</td>\n"; echo "<td>" . $row['Feuerwehr'] . "</td>\n";
echo "<td>" . $row['Punkte'] . "</td>\n"; echo "<td>" . $row['Punkte'] . "</td>\n";
echo "<td>" . $row["Zeit"] . "</td>\n"; if ($row['Zeit'] != NULL) {
$time = get_time_str($con, $row['m_id'], $s_id);
echo "<td>" . $time . "</td>\n";
} else {
echo "<td>" . $row['Zeit'] . "</td>\n";
}
echo "</tr>\n"; echo "</tr>\n";
} }
echo "</tbody>\n"; echo "</tbody>\n";
@@ -159,3 +164,29 @@ function check_time($con, $m_id, $s_id) {
return true; 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;
}