convert clock time (database "records")
Posted: 23 Aug 2021, 09:51
Is there any chain or formula to change the data in the "records" database and present it in the game panel in clock (time) format ?
regards.
Bern
regards.
Bern
You mean you want to change the format how it is stored in the database? If true, there is no need (and no reason) to change that, because if you request data from the database you can get every format you want within the SQL request: https://www.w3schools.com/mysql/func_my ... format.asp
I don't know if I have explained myself well, I never learned English ^^undef.de wrote: ↑23 Aug 2021, 12:44You mean you want to change the format how it is stored in the database? If true, there is no need (and no reason) to change that, because if you request data from the database you can get every format you want within the SQL request: https://www.w3schools.com/mysql/func_my ... format.asp
Code: Select all
$xml .='<label pos="59 '. $hauteur .'" z-index="0.005" size="30 7.5" textcolor="FFF" halign="right" style="TextSPScoreMedium" text="' . $formatTime. $row->Temps.'"></label>';
bern wrote: ↑24 Aug 2021, 09:42 I found the correct code ......![]()
Code: Select all
$aseco->formatTime($row->Temps)
Code: Select all
private function formatTimeColored ($MwTime) {
if ($MwTime > 0) {
$tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime);
$MwTime = floor($MwTime / 1000);
$hours = floor($MwTime / 3600);
$MwTime = $MwTime - ($hours * 3600);
$minutes = floor($MwTime / 60);
$MwTime = $MwTime - ($minutes * 60);
$seconds = floor($MwTime);
if ($tsec) {
if ($hours) {
return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d$FFF.$FF0%03d', $hours, $minutes, $seconds, $tseconds);
}
else {
return sprintf('$F00%d$FFF:$0C0%02d$FFF.$FF0%03d', $minutes, $seconds, $tseconds);
}
}
else {
if ($hours) {
return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d', $hours, $minutes, $seconds);
}
else {
return sprintf('$F00%d$FFF:$0C0%02d', $minutes, $seconds);
}
}
}
else {
return '0:00:000';
}
}
Code: Select all
$this->formatTimeColored($row->Temps)
First of all thanks for the support and resolution of the problemundef.de wrote: ↑24 Aug 2021, 20:02bern wrote: ↑24 Aug 2021, 09:42 I found the correct code ......![]()
Code: Select all
$aseco->formatTime($row->Temps)
Untested... but should do it.:
Paste the function formatTimeColored() into your plugin...... and call:Code: Select all
private function formatTimeColored ($MwTime) { if ($MwTime > 0) { $tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime); $MwTime = floor($MwTime / 1000); $hours = floor($MwTime / 3600); $MwTime = $MwTime - ($hours * 3600); $minutes = floor($MwTime / 60); $MwTime = $MwTime - ($minutes * 60); $seconds = floor($MwTime); if ($tsec) { if ($hours) { return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d$FFF.$FF0%03d', $hours, $minutes, $seconds, $tseconds); } else { return sprintf('$F00%d$FFF:$0C0%02d$FFF.$FF0%03d', $minutes, $seconds, $tseconds); } } else { if ($hours) { return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d', $hours, $minutes, $seconds); } else { return sprintf('$F00%d$FFF:$0C0%02d', $minutes, $seconds); } } } else { return '0:00:000'; } }
Code: Select all
$this->formatTimeColored($row->Temps)
Code: Select all
private function formatTimeColored ($MwTime) {
if ($MwTime > 0) {
$tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime);
$MwTime = floor($MwTime / 1000);
$days = floor($MwTime / 86400);
$MwTime = $MwTime - ($days * 86400);
$hours = floor($MwTime / 3600);
$MwTime = $MwTime - ($hours * 3600);
$minutes = floor($MwTime / 60);
$MwTime = $MwTime - ($minutes * 60);
$seconds = floor($MwTime);
if ($tseconds) {
if ($days) {
return sprintf('$FF9%d$FFF:$FFF%02d$FFF:$FF9%02d$FFF:$FFC%03d', $days, $hours, $minutes, $seconds, $tseconds);
}
else {
return sprintf('$FF9%d$FFF:$FFF%02d$FFF:$FF9%02d$FFF:$FFC%03d', $hours, $minutes, $seconds, $tseconds);
}
}
}
else {
return '0:00:00:000';
}
}