@@ -152,9 +152,8 @@ export class HaTimePicker extends LitElement {
152
152
}
153
153
}
154
154
155
- private _hoursChanged ( ev : CustomEvent < { value : number } > ) {
155
+ private _hoursChanged ( ev : CustomEvent < { clamped : boolean ; value : number } > ) {
156
156
const value = ev . detail . value ;
157
- console . log ( { originalValue : this . value } , "hoursChanged" , value ) ;
158
157
if ( this . _useAmPm ) {
159
158
if ( value > 12 ) {
160
159
this . _hours = value - 12 ;
@@ -168,36 +167,45 @@ export class HaTimePicker extends LitElement {
168
167
}
169
168
}
170
169
171
- private _minutesChanged ( ev : CustomEvent < { value : number } > ) {
172
- console . log (
173
- { originalValue : this . value } ,
174
- "minutesChanged" ,
175
- ev . detail . value
176
- ) ;
170
+ private _minutesChanged (
171
+ ev : CustomEvent < { clamped : boolean ; value : number } >
172
+ ) {
177
173
this . _minutes = ev . detail . value ;
174
+ if ( ev . detail . clamped ) {
175
+ if ( ev . detail . value <= 0 ) {
176
+ this . _hours -= 1 ;
177
+ this . _minutes = 59 ;
178
+ }
179
+
180
+ if ( ev . detail . value >= 59 ) {
181
+ this . _hours += 1 ;
182
+ this . _minutes = 0 ;
183
+ }
184
+ }
178
185
}
179
186
180
- private _secondsChanged ( ev : CustomEvent < { value : number } > ) {
181
- console . log (
182
- { originalValue : this . value } ,
183
- "secondsChanged" ,
184
- ev . detail . value
185
- ) ;
187
+ private _secondsChanged (
188
+ ev : CustomEvent < { clamped : boolean ; value : number } >
189
+ ) {
186
190
this . _seconds = ev . detail . value ;
191
+ if ( ev . detail . clamped ) {
192
+ if ( ev . detail . value <= 0 ) {
193
+ this . _minutes -= 1 ;
194
+ this . _seconds = 59 ;
195
+ }
196
+
197
+ if ( ev . detail . value >= 59 ) {
198
+ this . _minutes += 1 ;
199
+ this . _seconds = 0 ;
200
+ }
201
+ }
187
202
}
188
203
189
204
private _toggleAmPm ( ) {
190
205
this . _hours = this . _hours > 12 ? this . _hours - 12 : this . _hours + 12 ;
191
206
}
192
207
193
208
private _timeUpdated ( ) {
194
- console . log (
195
- { originalValue : this . value } ,
196
- "timeUpdated" ,
197
- this . _hours ,
198
- this . _minutes ,
199
- this . _seconds
200
- ) ;
201
209
const timeParts = [
202
210
this . _hours . toString ( ) . padStart ( 2 , "0" ) ,
203
211
this . _minutes . toString ( ) . padStart ( 2 , "0" ) ,
0 commit comments