mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Prevent optional time fields in ha-service-control from auto-enabling (#15124)
* Fix select box overflowing entities-row * Revert "Fix select box overflowing entities-row" This reverts commit b4e668dd064614cf2e544c0d1ea24256703ab84c. * Fix optional time fields in service control from auto-enabling
This commit is contained in:
parent
88ee409987
commit
38c1112308
@ -58,20 +58,32 @@ export class HaTimeInput extends LitElement {
|
|||||||
const eventValue = ev.detail.value;
|
const eventValue = ev.detail.value;
|
||||||
|
|
||||||
const useAMPM = useAmPm(this.locale);
|
const useAMPM = useAmPm(this.locale);
|
||||||
let hours = eventValue.hours || 0;
|
let value;
|
||||||
if (eventValue && useAMPM) {
|
|
||||||
if (eventValue.amPm === "PM" && hours < 12) {
|
if (
|
||||||
hours += 12;
|
!isNaN(eventValue.hours) ||
|
||||||
}
|
!isNaN(eventValue.minutes) ||
|
||||||
if (eventValue.amPm === "AM" && hours === 12) {
|
!isNaN(eventValue.seconds)
|
||||||
hours = 0;
|
) {
|
||||||
|
let hours = eventValue.hours || 0;
|
||||||
|
if (eventValue && useAMPM) {
|
||||||
|
if (eventValue.amPm === "PM" && hours < 12) {
|
||||||
|
hours += 12;
|
||||||
|
}
|
||||||
|
if (eventValue.amPm === "AM" && hours === 12) {
|
||||||
|
hours = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
value = `${hours.toString().padStart(2, "0")}:${
|
||||||
|
eventValue.minutes
|
||||||
|
? eventValue.minutes.toString().padStart(2, "0")
|
||||||
|
: "00"
|
||||||
|
}:${
|
||||||
|
eventValue.seconds
|
||||||
|
? eventValue.seconds.toString().padStart(2, "0")
|
||||||
|
: "00"
|
||||||
|
}`;
|
||||||
}
|
}
|
||||||
const value = `${hours.toString().padStart(2, "0")}:${
|
|
||||||
eventValue.minutes ? eventValue.minutes.toString().padStart(2, "0") : "00"
|
|
||||||
}:${
|
|
||||||
eventValue.seconds ? eventValue.seconds.toString().padStart(2, "0") : "00"
|
|
||||||
}`;
|
|
||||||
|
|
||||||
if (value === this.value) {
|
if (value === this.value) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user