Refactor age pretty printing

This commit is contained in:
RunasSudo 2024-08-27 17:35:18 +10:00
parent b2f71133ae
commit 9f40645d8a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -79,14 +79,24 @@ function exchange_thresh(d, gestation) {
// --------------
// Utility functions
function prettyPrintHours(d) {
if (d < 0.5/24) {
return '0 hours';
}
if (d < 1.5/24) {
return '1 hour';
}
return (d * 24).toFixed(0) + ' hours';
}
function prettyPrintDays(d) {
if (d < 1) {
return (d * 24).toFixed(0) + ' hours';
return prettyPrintHours(d);
}
if (d < 2) {
return '1 day, ' + ((d % 1) * 24).toFixed(0) + ' hours';
return '1 day, ' + prettyPrintHours(d % 1);
}
return Math.floor(d) + ' days, ' + ((d % 1) * 24).toFixed(0) + ' hours';
return Math.floor(d) + ' days, ' + prettyPrintHours(d % 1);
}
function prettyPrintBilirubin(b) {