From 3125108ff24264a80159bbf8cb09b42ecf325e51 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 30 Dec 2015 09:41:01 -0800 Subject: [PATCH] Make time since last event rendering clearer. --- static/babystats.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/babystats.js b/static/babystats.js index 060a788..d824a35 100644 --- a/static/babystats.js +++ b/static/babystats.js @@ -638,11 +638,11 @@ BabyStats.prototype.buildGrid_ = function() { */ BabyStats.prototype.secondsToHuman_ = function(seconds) { if (seconds > 60 * 60 * 24) { - return Math.round(seconds / (60 * 60 * 24)).toString() + 'd'; + return Math.floor(seconds / (60 * 60 * 24)).toString() + 'd'; } else if (seconds > 60 * 60) { - return Math.round(seconds / (60 * 60)).toString() + 'h'; + return Math.floor(seconds / (60 * 60)).toString() + 'h'; } else { - return Math.round(seconds / 60).toString() + 'm'; + return Math.floor(seconds / 60).toString() + 'm'; } }; @@ -655,7 +655,8 @@ BabyStats.prototype.updateTileStatus_ = function() { this.tiles_.forEach(function(tile) { if (tile.lastSeen) { var timeSince = now - tile.lastSeen; - tile.statusBox.textContent = this.secondsToHuman_(timeSince) + ' ago'; + tile.statusBox.textContent = ( + timeSince < 60 ? 'just now' : this.secondsToHuman_(timeSince) + ' ago'); var timedOut = tile.timeout && (now - tile.timeout > tile.lastSeen); if (tile.canceled || timedOut) { this.removeCSSClass_(tile.statusBox, 'babyStatsCellStatusActive');