mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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 useAMPM = useAmPm(this.locale);
|
||||
let hours = eventValue.hours || 0;
|
||||
if (eventValue && useAMPM) {
|
||||
if (eventValue.amPm === "PM" && hours < 12) {
|
||||
hours += 12;
|
||||
}
|
||||
if (eventValue.amPm === "AM" && hours === 12) {
|
||||
hours = 0;
|
||||
let value;
|
||||
|
||||
if (
|
||||
!isNaN(eventValue.hours) ||
|
||||
!isNaN(eventValue.minutes) ||
|
||||
!isNaN(eventValue.seconds)
|
||||
) {
|
||||
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) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user