Fix time display in home automation demo (#8392)

Show 12 instead of 0 for noon/midnight and fix AM/PM logic
This commit is contained in:
Tasuku Suzuki 2025-05-07 17:27:34 +09:00 committed by GitHub
parent 9289940371
commit 37ad2445a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,7 +140,7 @@ export component MainScreen inherits Rectangle {
if showing-time: HorizontalLayout {
alignment: center;
HaText {
text: Api.current-time.hour.mod(12);
text: Api.current-time.hour.mod(12) == 0 ? 12 : Api.current-time.hour.mod(12);
horizontal-alignment: center;
vertical-alignment: center;
color: Palette.info-foreground;
@ -164,7 +164,7 @@ export component MainScreen inherits Rectangle {
}
HaText {
text: Api.current-time.hour > 12 ? " PM" : " AM";
text: Api.current-time.hour >= 12 ? " PM" : " AM";
horizontal-alignment: center;
vertical-alignment: center;
color: Palette.info-foreground;