handle negative duration (#1510)
This commit is contained in:
@@ -49,7 +49,7 @@ export default class KimaiActiveRecordsDuration extends KimaiPlugin {
|
||||
const since = record.getAttribute('data-since');
|
||||
const format = record.getAttribute('data-format');
|
||||
const duration = this.formatDuration(since, format);
|
||||
if (record.getAttribute('data-title') !== null) {
|
||||
if (record.getAttribute('data-title') !== null && duration !== '?') {
|
||||
durations.push(duration);
|
||||
}
|
||||
record.textContent = duration;
|
||||
@@ -75,6 +75,10 @@ export default class KimaiActiveRecordsDuration extends KimaiPlugin {
|
||||
let minutes = duration.minutes();
|
||||
let seconds = duration.seconds();
|
||||
|
||||
if (hours < 0 || minutes < 0 || seconds < 0) {
|
||||
return '?';
|
||||
}
|
||||
|
||||
// special case for hours, as they can overflow the 24h barrier - Kimai does not support days as duration unit
|
||||
if (hours.length === 1) {
|
||||
hours = '0' + hours;
|
||||
|
||||
Reference in New Issue
Block a user