diff --git a/src/util/tooltip.js b/src/util/tooltip.js index 16c67792..4cabd99e 100644 --- a/src/util/tooltip.js +++ b/src/util/tooltip.js @@ -9,36 +9,48 @@ export function buildTooltip(bucket, e) { // WARNING: XSS risk, make sure to sanitize properly // FIXME: Not actually tested against XSS attacks, implementation needs to be verified in tests. let inner = 'Unknown bucket type'; + + // if same day, don't show date + let start = moment(e.timestamp); + let stop = moment(e.timestamp).add(e.duration, 'seconds'); + if (start.isSame(stop, 'day')) { + start = start.format('HH:mm:ss'); + stop = stop.format('HH:mm:ss'); + } else { + start = start.format('YYYY-MM-DD HH:mm:ss'); + stop = stop.format('YYYY-MM-DD HH:mm:ss'); + } + if (bucket.type == 'currentwindow') { inner = ` -
Start: | ${moment(e.timestamp).format()} |
---|---|
Stop: | ${moment(e.timestamp).add(e.duration, 'seconds').format()} |
Duration: | ${seconds_to_duration(e.duration)} |
Start | ${start} |
Stop | ${stop} |
Duration | ${seconds_to_duration(e.duration)} |