Skip to content

Commit 347a40e

Browse files
authored
Merge branch 'master' into vslavov/input-group-disabled
2 parents 23634b1 + 9f667f9 commit 347a40e

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,29 @@ describe('IgxTimePicker', () => {
11861186
expect(selectedAMPM).toEqual(ampm);
11871187
}));
11881188

1189+
it('should display correctly non-zero padded time format', fakeAsync(() => {
1190+
fixture.componentInstance.date = new Date(2021, 24, 2, 8, 5, 5);
1191+
fixture.componentInstance.timePicker.mode = PickerInteractionMode.DropDown;
1192+
timePicker.inputFormat = 'h:m:s';
1193+
fixture.detectChanges();
1194+
1195+
timePicker.open();
1196+
tick();
1197+
fixture.detectChanges();
1198+
1199+
const selectedItems = fixture.debugElement.queryAll(By.css(CSS_CLASS_SELECTED_ITEM));
1200+
const selectedHour = selectedItems[0].nativeElement.innerText;
1201+
const selectedMinutes = selectedItems[1].nativeElement.innerText;
1202+
const selectedAMPM = selectedItems[2].nativeElement.innerText;
1203+
1204+
const hours = fixture.componentInstance.date.getHours();
1205+
const minutes = fixture.componentInstance.date.getMinutes();
1206+
const seconds = fixture.componentInstance.date.getSeconds();
1207+
1208+
expect(selectedHour).toEqual(hours.toString());
1209+
expect(selectedMinutes).toEqual(minutes.toString());
1210+
expect(selectedAMPM).toEqual(seconds.toString());
1211+
}));
11891212

11901213
it('should display selected time in dialog header', fakeAsync(() => {
11911214
fixture.componentInstance.timePicker.mode = PickerInteractionMode.Dialog;

projects/igniteui-angular/src/lib/time-picker/time-picker.directives.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,19 @@ export class IgxTimeItemDirective {
264264
}
265265

266266
public get isSelectedTime(): boolean {
267+
const currentValue = this.value.length < 2 ? `0${this.value}` : this.value;
267268
const dateType = this.itemList.type;
268269
const inputDateParts = DateTimeUtil.parseDateTimeFormat(this.timePicker.inputFormat);
269270
switch (dateType) {
270271
case 'hourList':
271272
const hourPart = inputDateParts.find(element => element.type === 'hours');
272-
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, hourPart, hourPart.format.length) === this.value;
273+
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, hourPart, hourPart.format.length) === currentValue;
273274
case 'minuteList':
274275
const minutePart = inputDateParts.find(element => element.type === 'minutes');
275-
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, minutePart, minutePart.format.length) === this.value;
276+
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, minutePart, minutePart.format.length) === currentValue;
276277
case 'secondsList':
277278
const secondsPart = inputDateParts.find(element => element.type === 'seconds');
278-
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, secondsPart, secondsPart.format.length) === this.value;
279+
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, secondsPart, secondsPart.format.length) === currentValue;
279280
case 'ampmList':
280281
const ampmPart = inputDateParts.find(element => element.format === 'tt');
281282
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, ampmPart, ampmPart.format.length) === this.value;

0 commit comments

Comments
 (0)