fix(energiediagramm): Symcon-8-Darstellung korrigieren

This commit is contained in:
dh
2026-09-29 06:24:29 +00:00
parent 1f945be8f1
commit 40c6a17dd1
6 changed files with 52 additions and 14 deletions
+13 -3
View File
@@ -118,9 +118,19 @@ final class EnergyChartCalculator
public static function normalizeColor(string $color, string $fallback): string
{
return preg_match('/^#[0-9A-Fa-f]{6}$/', $color) === 1
? strtoupper($color)
: strtoupper($fallback);
$color = trim($color);
if (preg_match('/^#[0-9A-Fa-f]{6}$/', $color) === 1) {
return strtoupper($color);
}
if (preg_match('/^[0-9]+$/', $color) === 1) {
$legacyColor = (int) $color;
if ($legacyColor >= 0 && $legacyColor <= 0xFFFFFF) {
return sprintf('#%06X', $legacyColor);
}
}
return strtoupper($fallback);
}
private static function date(string $date): DateTimeImmutable