@@ -305,6 +305,10 @@ export class IgxTimePickerComponent extends PickerBaseDirective
305
305
@ViewChild ( 'secondsList' )
306
306
public secondsList : ElementRef ;
307
307
308
+ /** @hidden */
309
+ @ViewChild ( 'fractionalSecondsList' )
310
+ public fractionalSecondsList : ElementRef ;
311
+
308
312
/** @hidden */
309
313
@ViewChild ( 'ampmList' )
310
314
public ampmList : ElementRef ;
@@ -352,7 +356,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
352
356
}
353
357
if ( DateTimeUtil . isValidDate ( this . value ) ) {
354
358
// TODO: Update w/ clear behavior
355
- return this . value . getHours ( ) !== 0 || this . value . getMinutes ( ) !== 0 || this . value . getSeconds ( ) !== 0 ;
359
+ return this . value . getHours ( ) !== 0 || this . value . getMinutes ( ) !== 0 ||
360
+ this . value . getSeconds ( ) !== 0 || this . value . getMilliseconds ( ) !== 0 ;
356
361
}
357
362
return ! ! this . dateTimeEditor . value ;
358
363
}
@@ -372,6 +377,12 @@ export class IgxTimePickerComponent extends PickerBaseDirective
372
377
return this . inputFormat . indexOf ( 's' ) !== - 1 ;
373
378
}
374
379
380
+
381
+ /** @hidden */
382
+ public get showFractionalSecondsList ( ) : boolean {
383
+ return this . inputFormat . indexOf ( 'S' ) !== - 1 ;
384
+ }
385
+
375
386
/** @hidden */
376
387
public get showAmPmList ( ) : boolean {
377
388
return this . inputFormat . indexOf ( 't' ) !== - 1 || this . inputFormat . indexOf ( 'a' ) !== - 1 ;
@@ -445,6 +456,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
445
456
/** @hidden @internal */
446
457
public secondsItems = [ ] ;
447
458
/** @hidden @internal */
459
+ public fractionalSecondsItems = [ ] ;
460
+ /** @hidden @internal */
448
461
public ampmItems = [ ] ;
449
462
450
463
private _value : Date | string ;
@@ -455,7 +468,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
455
468
private _resourceStrings = getCurrentResourceStrings ( TimePickerResourceStringsEN ) ;
456
469
private _okButtonLabel = null ;
457
470
private _cancelButtonLabel = null ;
458
- private _itemsDelta : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' > = { hours : 1 , minutes : 1 , seconds : 1 } ;
471
+ private _itemsDelta : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' | 'fractionalSeconds' > =
472
+ { hours : 1 , minutes : 1 , seconds : 1 , fractionalSeconds : 1 } ;
459
473
460
474
private _statusChanges$ : Subscription ;
461
475
private _ngControl : NgControl = null ;
@@ -596,11 +610,11 @@ export class IgxTimePickerComponent extends PickerBaseDirective
596
610
* ```
597
611
*/
598
612
@Input ( )
599
- public set itemsDelta ( value : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' > ) {
613
+ public set itemsDelta ( value : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' | 'fractionalSeconds' > ) {
600
614
Object . assign ( this . _itemsDelta , value ) ;
601
615
}
602
616
603
- public get itemsDelta ( ) : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' > {
617
+ public get itemsDelta ( ) : Pick < DatePartDeltas , 'hours' | 'minutes' | 'seconds' | 'fractionalSeconds' > {
604
618
return this . _itemsDelta ;
605
619
}
606
620
@@ -653,6 +667,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
653
667
hour : '2-digit' ,
654
668
minute : '2-digit' ,
655
669
second : '2-digit' ,
670
+ fractionalSecondDigits : 3
656
671
} ) ;
657
672
}
658
673
@@ -664,7 +679,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
664
679
const date = this . parseToDate ( value ) ;
665
680
if ( date ) {
666
681
this . _dateValue = new Date ( ) ;
667
- this . _dateValue . setHours ( date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) ) ;
682
+ this . _dateValue . setHours ( date . getHours ( ) , date . getMinutes ( ) , date . getSeconds ( ) , date . getMilliseconds ( ) ) ;
668
683
this . setSelectedValue ( this . _dateValue ) ;
669
684
} else {
670
685
this . setSelectedValue ( null ) ;
@@ -824,10 +839,10 @@ export class IgxTimePickerComponent extends PickerBaseDirective
824
839
825
840
if ( DateTimeUtil . isValidDate ( this . value ) ) {
826
841
const oldValue = new Date ( this . value ) ;
827
- this . value . setHours ( 0 , 0 , 0 ) ;
842
+ this . value . setHours ( 0 , 0 , 0 , 0 ) ;
828
843
if ( this . value . getTime ( ) !== oldValue . getTime ( ) ) {
829
844
this . emitValueChange ( oldValue , this . value ) ;
830
- this . _dateValue . setHours ( 0 , 0 , 0 ) ;
845
+ this . _dateValue . setHours ( 0 , 0 , 0 , 0 ) ;
831
846
this . dateTimeEditor . value = new Date ( this . value ) ;
832
847
this . setSelectedValue ( this . _dateValue ) ;
833
848
}
@@ -932,6 +947,14 @@ export class IgxTimePickerComponent extends PickerBaseDirective
932
947
}
933
948
break ;
934
949
}
950
+ case 'fractionalSecondsList' : {
951
+ const fractionalSeconds = parseInt ( item , 10 ) ;
952
+ date . setMilliseconds ( fractionalSeconds ) ;
953
+ if ( this . valueInRange ( date , this . minDropdownValue , this . maxDropdownValue ) ) {
954
+ this . setSelectedValue ( date ) ;
955
+ }
956
+ break ;
957
+ }
935
958
case 'ampmList' : {
936
959
let hour = this . _selectedDate . getHours ( ) ;
937
960
hour = item === 'AM' || item === 'a' ? hour - 12 : hour + 12 ;
@@ -1013,6 +1036,36 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1013
1036
this . updateEditorValue ( ) ;
1014
1037
}
1015
1038
1039
+ /** @hidden @internal */
1040
+ public nextFractionalSeconds ( delta : number ) {
1041
+ delta = delta > 0 ? 1 : - 1 ;
1042
+ const minHours = this . minDropdownValue . getHours ( ) ;
1043
+ const maxHours = this . maxDropdownValue . getHours ( ) ;
1044
+ const hours = this . _selectedDate . getHours ( ) ;
1045
+ const minutes = this . _selectedDate . getMinutes ( ) ;
1046
+ const minMinutes = this . minDropdownValue . getMinutes ( ) ;
1047
+ const maxMinutes = this . maxDropdownValue . getMinutes ( ) ;
1048
+ const seconds = this . _selectedDate . getSeconds ( ) ;
1049
+ const minSeconds = this . minDropdownValue . getSeconds ( ) ;
1050
+ const maxSeconds = this . maxDropdownValue . getSeconds ( ) ;
1051
+ let ms = this . _selectedDate . getMilliseconds ( ) ;
1052
+ const minMs = ( hours === minHours && minutes === minMinutes && seconds === minSeconds ) ? this . minDropdownValue . getMilliseconds ( ) : 0 ;
1053
+ const maxMs = ( hours === maxHours && minutes === maxMinutes && seconds === maxSeconds ) ? this . maxDropdownValue . getMilliseconds ( ) :
1054
+ 1000 % this . itemsDelta . fractionalSeconds > 0 ? 1000 - ( 1000 % this . itemsDelta . fractionalSeconds ) :
1055
+ 1000 - this . itemsDelta . fractionalSeconds ;
1056
+
1057
+ if ( ( delta < 0 && ms === minMs ) || ( delta > 0 && ms === maxMs ) ) {
1058
+ ms = this . spinLoop && ms === minMs ? maxMs : this . spinLoop && ms === maxMs ? minMs : ms ;
1059
+ } else {
1060
+ ms = ms + delta * this . itemsDelta . fractionalSeconds ;
1061
+ }
1062
+
1063
+ this . _selectedDate . setMilliseconds ( ms ) ;
1064
+ this . _selectedDate = this . validateDropdownValue ( this . _selectedDate ) ;
1065
+ this . _selectedDate = new Date ( this . _selectedDate ) ;
1066
+ this . updateEditorValue ( ) ;
1067
+ }
1068
+
1016
1069
/** @hidden @internal */
1017
1070
public nextAmPm ( delta ?: number ) {
1018
1071
const ampm = this . getPartValue ( this . _selectedDate , 'ampm' ) ;
@@ -1065,6 +1118,12 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1065
1118
this . _selectedDate . getSeconds ( ) + this . itemsDelta . seconds - this . _selectedDate . getSeconds ( ) % this . itemsDelta . seconds
1066
1119
) ;
1067
1120
}
1121
+
1122
+ if ( this . _selectedDate . getMilliseconds ( ) % this . itemsDelta . fractionalSeconds > 0 ) {
1123
+ this . _selectedDate . setMilliseconds (
1124
+ this . _selectedDate . getMilliseconds ( ) + this . itemsDelta . fractionalSeconds - this . _selectedDate . getMilliseconds ( ) % this . itemsDelta . fractionalSeconds
1125
+ ) ;
1126
+ }
1068
1127
}
1069
1128
1070
1129
protected onStatusChanged ( ) {
@@ -1100,6 +1159,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1100
1159
const hours = time . getHours ( ) ;
1101
1160
let minutes = time . getMinutes ( ) ;
1102
1161
let seconds = time . getSeconds ( ) ;
1162
+ const milliseconds = time . getMilliseconds ( ) ;
1103
1163
1104
1164
if ( this . showHoursList && hours % this . itemsDelta . hours > 0 ) {
1105
1165
delta = type === 'min' ? this . itemsDelta . hours - hours % this . itemsDelta . hours
@@ -1110,18 +1170,22 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1110
1170
seconds = type === 'min' ? 0
1111
1171
: 60 % this . itemsDelta . seconds > 0 ? 60 - 60 % this . itemsDelta . seconds
1112
1172
: 60 - this . itemsDelta . seconds ;
1113
- time . setHours ( hours + sign * delta , minutes , seconds ) ;
1173
+ time . setHours ( hours + sign * delta , minutes , seconds , milliseconds ) ;
1114
1174
} else if ( this . showMinutesList && minutes % this . itemsDelta . minutes > 0 ) {
1115
1175
delta = type === 'min' ? this . itemsDelta . minutes - minutes % this . itemsDelta . minutes
1116
1176
: minutes % this . itemsDelta . minutes ;
1117
1177
seconds = type === 'min' ? 0
1118
1178
: 60 % this . itemsDelta . seconds > 0 ? 60 - 60 % this . itemsDelta . seconds
1119
1179
: 60 - this . itemsDelta . seconds ;
1120
- time . setHours ( hours , minutes + sign * delta , seconds ) ;
1180
+ time . setHours ( hours , minutes + sign * delta , seconds , milliseconds ) ;
1121
1181
} else if ( this . showSecondsList && seconds % this . itemsDelta . seconds > 0 ) {
1122
1182
delta = type === 'min' ? this . itemsDelta . seconds - seconds % this . itemsDelta . seconds
1123
1183
: seconds % this . itemsDelta . seconds ;
1124
- time . setHours ( hours , minutes , seconds + sign * delta ) ;
1184
+ time . setHours ( hours , minutes , seconds + sign * delta , milliseconds ) ;
1185
+ } else if ( this . showFractionalSecondsList && milliseconds % this . itemsDelta . fractionalSeconds > 0 ) {
1186
+ delta = type === 'min' ? this . itemsDelta . fractionalSeconds - milliseconds % this . itemsDelta . fractionalSeconds
1187
+ : milliseconds % this . itemsDelta . fractionalSeconds ;
1188
+ time . setHours ( hours , minutes , seconds , milliseconds + sign * delta ) ;
1125
1189
}
1126
1190
1127
1191
return time ;
@@ -1135,6 +1199,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1135
1199
this . minuteList . nativeElement . focus ( ) ;
1136
1200
} else if ( this . secondsList ) {
1137
1201
this . secondsList . nativeElement . focus ( ) ;
1202
+ } else if ( this . fractionalSecondsList ) {
1203
+ this . fractionalSecondsList . nativeElement . focus ( ) ;
1138
1204
}
1139
1205
} ) ;
1140
1206
}
@@ -1211,7 +1277,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1211
1277
this . value = newValue ? new Date ( newValue ) : newValue ;
1212
1278
} else if ( isDate ( this . value ) ) {
1213
1279
const date = new Date ( this . value ) ;
1214
- date . setHours ( newValue ?. getHours ( ) || 0 , newValue ?. getMinutes ( ) || 0 , newValue ?. getSeconds ( ) || 0 ) ;
1280
+ date . setHours ( newValue ?. getHours ( ) || 0 , newValue ?. getMinutes ( ) || 0 , newValue ?. getSeconds ( ) || 0 , newValue ?. getMilliseconds ( ) || 0 ) ;
1215
1281
this . value = date ;
1216
1282
} else {
1217
1283
this . value = newValue ? this . toISOString ( newValue ) : newValue ;
@@ -1220,7 +1286,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1220
1286
1221
1287
private updateEditorValue ( ) : void {
1222
1288
const date = this . dateTimeEditor . value ? new Date ( this . dateTimeEditor . value ) : new Date ( ) ;
1223
- date . setHours ( this . _selectedDate . getHours ( ) , this . _selectedDate . getMinutes ( ) , this . _selectedDate . getSeconds ( ) ) ;
1289
+ date . setHours ( this . _selectedDate . getHours ( ) , this . _selectedDate . getMinutes ( ) , this . _selectedDate . getSeconds ( ) , this . _selectedDate . getMilliseconds ( ) ) ;
1224
1290
this . dateTimeEditor . value = date ;
1225
1291
}
1226
1292
0 commit comments