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