From daca2039dbc28207445ad2e0642b78e9b781ee68 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 10 Dec 2024 10:45:54 +0100 Subject: [PATCH] Use difference in days --- .../config/backup/components/ha-backup-summary-status.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/config/backup/components/ha-backup-summary-status.ts b/src/panels/config/backup/components/ha-backup-summary-status.ts index 9737726667c1..cfb16bac9dc4 100644 --- a/src/panels/config/backup/components/ha-backup-summary-status.ts +++ b/src/panels/config/backup/components/ha-backup-summary-status.ts @@ -1,3 +1,4 @@ +import { differenceInDays } from "date-fns"; import { html, LitElement } from "lit"; import { customElement, property } from "lit/decorators"; import memoizeOne from "memoize-one"; @@ -47,8 +48,7 @@ export class HaBackupSummaryProgress extends LitElement { } const lastBackupDate = new Date(lastBackup.date); - const lastBackupPeriod = new Date().getTime() - lastBackupDate.getTime(); - const numberOfDays = Math.floor(lastBackupPeriod / (1000 * 60 * 60 * 24)); + const numberOfDays = differenceInDays(new Date(), lastBackupDate); // TODO : Improve time format const description = `Last successful backup ${formatShortDateTime(lastBackupDate, this.hass.locale, this.hass.config)} and synced to ${lastBackup.agent_ids?.length} locations`;