Use smaller units for slightly higher numbers, to add some more detail in cases that used to just say "1h"
This commit is contained in:
@@ -704,15 +704,17 @@ BabyStats.prototype.buildGrid_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {number} seconds
|
* @param {number} seconds
|
||||||
|
* @param {?function} opt_floatToInt
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
BabyStats.prototype.secondsToHuman_ = function(seconds) {
|
BabyStats.prototype.secondsToHuman_ = function(seconds, opt_floatToInt) {
|
||||||
if (seconds > 60 * 60 * 24) {
|
var floatToInt = opt_floatToInt || Math.floor;
|
||||||
return Math.floor(seconds / (60 * 60 * 24)).toString() + 'd';
|
if (seconds > 60 * 60 * 24 * 2) {
|
||||||
} else if (seconds > 60 * 60) {
|
return floatToInt(seconds / (60 * 60 * 24)).toString() + 'd';
|
||||||
return Math.floor(seconds / (60 * 60)).toString() + 'h';
|
} else if (seconds > 60 * 60 * 2) {
|
||||||
|
return floatToInt(seconds / (60 * 60)).toString() + 'h';
|
||||||
} else {
|
} else {
|
||||||
return Math.floor(seconds / 60).toString() + 'm';
|
return floatToInt(seconds / 60).toString() + 'm';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -806,7 +808,7 @@ BabyStats.prototype.updateDisplayPage_ = function() {
|
|||||||
}
|
}
|
||||||
deltas.sort();
|
deltas.sort();
|
||||||
var median = deltas[Math.floor(deltas.length / 2)];
|
var median = deltas[Math.floor(deltas.length / 2)];
|
||||||
text += '\n⏱ ' + this.secondsToHuman_(median);
|
text += '\n⏱ ' + this.secondsToHuman_(median, Math.round);
|
||||||
}
|
}
|
||||||
this.displayEventCountCells_[tile.type][cutoff[0]].textContent = text;
|
this.displayEventCountCells_[tile.type][cutoff[0]].textContent = text;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|||||||
Reference in New Issue
Block a user