Refactor age pretty printing
This commit is contained in:
parent
b2f71133ae
commit
9f40645d8a
@ -79,14 +79,24 @@ function exchange_thresh(d, gestation) {
|
|||||||
// --------------
|
// --------------
|
||||||
// Utility functions
|
// 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) {
|
function prettyPrintDays(d) {
|
||||||
if (d < 1) {
|
if (d < 1) {
|
||||||
return (d * 24).toFixed(0) + ' hours';
|
return prettyPrintHours(d);
|
||||||
}
|
}
|
||||||
if (d < 2) {
|
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) {
|
function prettyPrintBilirubin(b) {
|
||||||
|
Loading…
Reference in New Issue
Block a user