Quote from: HerrNove on August 27, 2025, 12:15:04 AMHi dreadnaut, I am a little confused by the "Submit time" screen after the update. It seems that the "Corrected time" row does not display the centiseconds of the raw time correctly (it shows 1:13:00 instead of 1:13:95).
Curiously, the confirmation screen after submitting the time shows the centiseconds correctly.
Because it shows for some reason one of the SQL rounded cell time format, not the real one.
Here's what's happening — and how to fix it.
What's the bug?
On the Submit time page, the "Corrected time" line prints the raw time with a formatter that drops centiseconds, while the corrected time on the right uses a centisecond-aware formatter.
Result: you see 1:13:00 – 10% = 1:06.55 even though the raw time is 1:13.95.
The confirmation screen uses the centisecond formatter consistently, so it looks correct there.
Why it happens
Somewhere in the template/back-end that builds the string
{raw} - {bonus}% = {corrected}
the left token uses a "mm:ss" formatter (seconds precision), while the right token uses "mm:ss.cc" (centiseconds). The math is fine; it's a display mismatch.
The fix
Use one centisecond formatter for every time you display (raw and corrected), on both pages.
Example (PHP)
function format_time_cs(int $centis): string {
$min = intdiv($centis, 6000);
$sec = intdiv($centis % 6000, 100);
$csec = $centis % 100;
return sprintf('%d:%02d.%02d', $min, $sec, $csec);
}
// Build the "Corrected time" row
$raw_cs = $time_centiseconds; // e.g., 4395 for 1:13.95
$bonus_pct = 10;
$corrected_cs = intdiv($raw_cs * (100 - $bonus_pct), 100); // truncate, don't round
$line = sprintf(
'%s - %d%% = %s',
format_time_cs($raw_cs),
$bonus_pct,
format_time_cs($corrected_cs)
);
Example (JS, if the page formats client-side)
function formatTimeCs(totalCs){
const m = Math.floor(totalCs / 6000);
const s = Math.floor((totalCs % 6000) / 100);
const c = totalCs % 100;
return `${m}:${String(s).padStart(2,'0')}.${String(c).padStart(2,'0')}`;
}
// corrected = truncate to centiseconds
const correctedCs = Math.floor(rawCs * (100 - bonusPct) / 100);
const line = `${formatTimeCs(rawCs)} - ${bonusPct}% = ${formatTimeCs(correctedCs)}`;
Also worth standardizing
Use mm:ss.cc (dot before centiseconds) everywhere for clarity.
Add a quick unit test for edge cases (e.g., 0:59.99 with 10%, 1:00.00, etc.) to ensure truncation, not rounding.
Once the submit page calls the same format_time_cs for both sides, the display will read:
1:13.95 – 10% = 1:06.55
which will match the confirmation screen.