Fix negative time elapsed

This commit is contained in:
everoddandeven 2024-12-28 19:57:44 +01:00
parent b8dceec47d
commit 13a4bb2237

View file

@ -24,9 +24,15 @@ export class DetailComponent extends BasePageComponent implements AfterViewInit
hours: '00'
};
}
const now = new Date();
const elapsedMilliseconds = now.getTime() - startedAt.getTime();
let elapsedMilliseconds = now.getTime() - startedAt.getTime();
if (elapsedMilliseconds < 0) {
console.warn("Elapsed time is negative");
this.daemonService.startedAt = now;
elapsedMilliseconds = 0;
}
const seconds = Math.floor((elapsedMilliseconds / 1000) % 60);
const minutes = Math.floor((elapsedMilliseconds / (1000 * 60)) % 60);