From 3dd4904a72b55cba94a3951a83dc2bd0d7caee09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Wiedemann?= Date: Tue, 19 Apr 2022 14:47:23 +0000 Subject: [PATCH] fix: `last_updated` date format was not following the configuration --- .devcontainer/ui-lovelace.yaml | 2 ++ src/apexcharts-card.ts | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/ui-lovelace.yaml b/.devcontainer/ui-lovelace.yaml index 096d926..2b3d5cc 100644 --- a/.devcontainer/ui-lovelace.yaml +++ b/.devcontainer/ui-lovelace.yaml @@ -92,6 +92,8 @@ views: floating: true - type: custom:apexcharts-card + show: + last_updated: true update_interval: 2s stacked: true experimental: diff --git a/src/apexcharts-card.ts b/src/apexcharts-card.ts index ea01fe8..2323dbb 100644 --- a/src/apexcharts-card.ts +++ b/src/apexcharts-card.ts @@ -24,6 +24,7 @@ import { decompress, getPercentFromValue, interpolateColor, + is12Hour, log, mergeConfigTemplates, mergeDeep, @@ -686,9 +687,7 @@ class ChartsCard extends LitElement { if (this._config?.show?.last_updated) { // eslint-disable-next-line @typescript-eslint/no-explicit-any let hours12: any = undefined; - if (this._config.hours_12 !== undefined) { - hours12 = this._config.hours_12 ? { hour12: true } : { hourCycle: 'h23' }; - } + hours12 = is12Hour(this._config, this._hass) ? { hour12: true } : { hourCycle: 'h23' }; const lastUpdated = new Intl.DateTimeFormat(this._config.locale || this._hass?.language || 'en', { year: 'numeric', month: 'short',