Round 23.5 hours+ to the next day when pretty printing
This commit is contained in:
parent
9f40645d8a
commit
8b39e849b1
|
@ -80,6 +80,10 @@ function exchange_thresh(d, gestation) {
|
|||
// Utility functions
|
||||
|
||||
function prettyPrintHours(d) {
|
||||
if (d >= 23.5/24) {
|
||||
throw new Error('>24 hours passed to prettyPrintHours');
|
||||
}
|
||||
|
||||
if (d < 0.5/24) {
|
||||
return '0 hours';
|
||||
}
|
||||
|
@ -90,13 +94,16 @@ function prettyPrintHours(d) {
|
|||
}
|
||||
|
||||
function prettyPrintDays(d) {
|
||||
if (d < 1) {
|
||||
if (d < 23.5/24) {
|
||||
return prettyPrintHours(d);
|
||||
}
|
||||
if (d < 2) {
|
||||
if (d < 1 + 23.5/24) {
|
||||
return '1 day, ' + prettyPrintHours(d % 1);
|
||||
}
|
||||
return Math.floor(d) + ' days, ' + prettyPrintHours(d % 1);
|
||||
|
||||
let d_rounded = Math.round(d * 24) / 24; // Round 23.5 hours+ to the next day
|
||||
|
||||
return Math.floor(d_rounded) + ' days, ' + prettyPrintHours(d_rounded % 1);
|
||||
}
|
||||
|
||||
function prettyPrintBilirubin(b) {
|
||||
|
|
Loading…
Reference in New Issue