@@ -50,6 +50,7 @@ import { ITimePickerResourceStrings } from '../core/i18n/time-picker-resources';
50
50
import { CurrentResourceStrings } from '../core/i18n/resources' ;
51
51
import { KEYS , CancelableBrowserEventArgs , IBaseEventArgs } from '../core/utils' ;
52
52
import { InteractionMode } from '../core/enums' ;
53
+ import { TimeParts } from './time-picker.common' ;
53
54
54
55
let NEXT_ID = 0 ;
55
56
const ITEMS_COUNT = 7 ;
@@ -636,78 +637,43 @@ export class IgxTimePickerComponent implements
636
637
}
637
638
638
639
/** @hidden @internal */
639
- applyDisabledStyleForHours ( hourString : string ) : boolean {
640
- const minValueDate : Date = this . convertMinMaxValue ( this . minValue )
641
- const maxValueDate : Date = this . convertMinMaxValue ( this . maxValue )
642
- if ( ! minValueDate || ! maxValueDate ) {
640
+ applyDisabledStyleForItem ( period : string , value : string ) {
641
+ if ( ! this . minValue || ! this . maxValue ) {
643
642
return false ;
644
643
}
645
- let hour = parseInt ( hourString , 10 ) ;
646
- if ( this . selectedAmPm === 'PM' ) {
647
- hour += 12 ;
648
- }
644
+ const minValueDate : Date = this . convertMinMaxValue ( this . minValue ) ;
645
+ const maxValueDate : Date = this . convertMinMaxValue ( this . maxValue ) ;
646
+ let hour : number = parseInt ( this . selectedHour , 10 ) ;
647
+ let minute : number = parseInt ( this . selectedMinute , 10 ) ;
648
+ let seconds : number = parseInt ( this . selectedSeconds , 10 ) ;
649
+ let amPM : string = this . selectedAmPm ;
649
650
const date = new Date ( minValueDate ) ;
650
- date . setHours ( hour ) ;
651
- return date < minValueDate || date > maxValueDate ;
652
- }
651
+ switch ( period ) {
652
+ case TimeParts . Hour :
653
+ hour = parseInt ( value , 10 ) ;
654
+ break ;
653
655
654
- /** @hidden @internal */
655
- applyDisabledStyleForMinutes ( minuteString : string ) : boolean {
656
- const minValueDate : Date = this . convertMinMaxValue ( this . minValue )
657
- const maxValueDate : Date = this . convertMinMaxValue ( this . maxValue )
658
- if ( ! minValueDate || ! maxValueDate ) {
659
- return false ;
660
- }
661
- const minute = parseInt ( minuteString , 10 ) ;
662
- let hour = parseInt ( this . selectedHour , 10 ) ;
663
- if ( this . selectedAmPm === 'PM' ) {
664
- hour += 12 ;
665
- }
666
- const date = new Date ( minValueDate ) ;
667
- date . setHours ( hour ) ;
668
- date . setMinutes ( minute ) ;
669
- return date < minValueDate || date > maxValueDate ;
670
- }
656
+ case TimeParts . Minute :
657
+ minute = parseInt ( value , 10 ) ;
658
+ break ;
671
659
672
- /** @hidden @internal */
673
- applyDisabledStyleForSeconds ( secondsString : string ) : boolean {
674
- const minValueDate : Date = this . convertMinMaxValue ( this . minValue )
675
- const maxValueDate : Date = this . convertMinMaxValue ( this . maxValue )
676
- if ( ! minValueDate || ! maxValueDate ) {
677
- return false ;
678
- }
679
- const minute = parseInt ( this . selectedMinute , 10 ) ;
680
- let hour = parseInt ( this . selectedHour , 10 ) ;
681
- const second = parseInt ( secondsString , 10 ) ;
682
- if ( this . selectedAmPm === 'PM' ) {
683
- hour += 12 ;
684
- }
685
- const date = new Date ( minValueDate ) ;
686
- date . setHours ( hour ) ;
687
- date . setMinutes ( minute ) ;
688
- date . setSeconds ( second ) ;
689
- return date < minValueDate || date > maxValueDate ;
690
- }
660
+ case TimeParts . Seconds :
661
+ seconds = parseInt ( value , 10 ) ;
662
+ break ;
691
663
692
- /** @hidden @internal */
693
- applyDisabledStyleForAmPm ( selectedAmPm ) : boolean {
694
- const minValueDate : Date = this . convertMinMaxValue ( this . minValue )
695
- const maxValueDate : Date = this . convertMinMaxValue ( this . maxValue )
696
- if ( ! minValueDate || ! maxValueDate ) {
697
- return false ;
664
+ case TimeParts . amPM :
665
+ amPM = value ;
666
+ break ;
698
667
}
699
- const minute = parseInt ( this . selectedMinute , 10 ) ;
700
- let hour = parseInt ( this . selectedHour , 10 ) ;
701
- const second = parseInt ( this . selectedSeconds , 10 ) ;
702
- const amPM = selectedAmPm ;
668
+
703
669
if ( amPM === 'PM' ) {
704
670
hour += 12 ;
705
671
}
706
- const date = new Date ( minValueDate ) ;
707
672
date . setHours ( hour ) ;
708
673
date . setMinutes ( minute ) ;
709
- date . setSeconds ( second ) ;
674
+ date . setSeconds ( seconds ) ;
710
675
return date < minValueDate || date > maxValueDate ;
676
+
711
677
}
712
678
713
679
/** @hidden @internal */
0 commit comments