@@ -29,7 +29,7 @@ export class MaskedDateTime {
29
29
private objectString : string [ ] ;
30
30
private hiddenMask : string = '' ;
31
31
private validCharacters : string = 'dMyhmHfasz' ;
32
- private value : Date ;
32
+ private maskDateValue : Date ;
33
33
private previousValue : string ;
34
34
private previousHiddenMask : string ;
35
35
private isDayPart : boolean = false ;
@@ -53,13 +53,13 @@ export class MaskedDateTime {
53
53
public constructor ( parent ? : IMaskedDateTime ) {
54
54
this . parent = parent ;
55
55
this . dateformat = this . getCulturedFormat ( ) ;
56
- this . value = this . parent . value != null ? this . parent . value : new Date ( ) ;
57
- this . value . setMonth ( 0 ) ;
58
- this . value . setHours ( 0 ) ;
59
- this . value . setMinutes ( 0 ) ;
60
- this . value . setSeconds ( 0 ) ;
61
- this . previousDate = new Date ( this . value . getFullYear ( ) , this . value . getMonth ( ) , this . value . getDate ( ) , this . value . getHours ( ) ,
62
- this . value . getMinutes ( ) , this . value . getSeconds ( ) ) ;
56
+ this . maskDateValue = this . parent . value != null ? this . parent . value : new Date ( ) ;
57
+ this . maskDateValue . setMonth ( 0 ) ;
58
+ this . maskDateValue . setHours ( 0 ) ;
59
+ this . maskDateValue . setMinutes ( 0 ) ;
60
+ this . maskDateValue . setSeconds ( 0 ) ;
61
+ this . previousDate = new Date ( this . maskDateValue . getFullYear ( ) , this . maskDateValue . getMonth ( ) , this . maskDateValue . getDate ( ) , this . maskDateValue . getHours ( ) ,
62
+ this . maskDateValue . getMinutes ( ) , this . maskDateValue . getSeconds ( ) ) ;
63
63
this . removeEventListener ( ) ;
64
64
this . addEventListener ( ) ;
65
65
}
@@ -155,7 +155,7 @@ export class MaskedDateTime {
155
155
}
156
156
}
157
157
private setDynamicValue ( ) : void {
158
- this . value = this . parent . value ;
158
+ this . maskDateValue = this . parent . value ;
159
159
this . isDayPart = this . isMonthPart = this . isYearPart = this . isHourPart = this . isMinutePart = this . isSecondsPart = true
160
160
this . updateValue ( ) ;
161
161
// this.parent.inputElement.selectionStart = start;
@@ -221,7 +221,7 @@ export class MaskedDateTime {
221
221
let inputValue : string = this . parent . inputElement . value ;
222
222
let previousVal : string = this . previousValue . substring ( 0 , start + this . previousValue . length - inputValue . length ) ;
223
223
let newVal : string = inputValue . substring ( 0 , start ) ;
224
- let newDateValue : Date = this . value ;
224
+ let newDateValue : Date = this . maskDateValue ;
225
225
226
226
let maxDate : number = new Date ( newDateValue . getFullYear ( ) , newDateValue . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
227
227
if ( previousVal . indexOf ( newVal ) === 0 && ( newVal . length === 0 || this . previousHiddenMask [ newVal . length - 1 ] !== this . previousHiddenMask [ newVal . length ] ) ) {
@@ -247,7 +247,7 @@ export class MaskedDateTime {
247
247
newDateValue . setDate ( date ) ;
248
248
this . isNavigate = date . toString ( ) . length === 2 ;
249
249
this . previousDate = new Date ( newDateValue . getFullYear ( ) , newDateValue . getMonth ( ) , newDateValue . getDate ( ) ) ;
250
- if ( newDateValue . getMonth ( ) !== this . value . getMonth ( ) ) {
250
+ if ( newDateValue . getMonth ( ) !== this . maskDateValue . getMonth ( ) ) {
251
251
return ;
252
252
}
253
253
this . isDayPart = true ;
@@ -299,7 +299,7 @@ export class MaskedDateTime {
299
299
if ( monthString [ i ] . toLowerCase ( ) . indexOf ( this . monthCharacter ) === 0 ) {
300
300
newDateValue . setMonth ( i - 1 ) ;
301
301
this . isMonthPart = true ;
302
- this . value = newDateValue ;
302
+ this . maskDateValue = newDateValue ;
303
303
return ;
304
304
}
305
305
i ++ ;
@@ -386,7 +386,7 @@ export class MaskedDateTime {
386
386
for ( let i : number = 0 ; this . periodCharacter . length > 0 ; i ++ ) {
387
387
if ( ( periodString [ periodkeys [ 0 ] ] . toLowerCase ( ) . indexOf ( this . periodCharacter ) === 0 && newDateValue . getHours ( ) >= 12 ) || ( periodString [ periodkeys [ 1 ] ] . toLowerCase ( ) . indexOf ( this . periodCharacter ) === 0 && newDateValue . getHours ( ) < 12 ) ) {
388
388
newDateValue . setHours ( ( newDateValue . getHours ( ) + 12 ) % 24 ) ;
389
- this . value = newDateValue ;
389
+ this . maskDateValue = newDateValue ;
390
390
}
391
391
this . periodCharacter = this . periodCharacter . substring ( 1 , this . periodCharacter . length ) ;
392
392
// Object.values()
@@ -395,7 +395,7 @@ export class MaskedDateTime {
395
395
default :
396
396
break ;
397
397
}
398
- this . value = newDateValue ;
398
+ this . maskDateValue = newDateValue ;
399
399
}
400
400
401
401
private formatCheck ( ) : any {
@@ -418,63 +418,63 @@ export class MaskedDateTime {
418
418
switch ( formattext ) {
419
419
case 'ddd' :
420
420
case 'dddd' :
421
- case 'd' : result = proxy . isDayPart ? proxy . value . getDate ( ) . toString ( ) : proxy . defaultConstant [ 'day' ] . toString ( ) ;
421
+ case 'd' : result = proxy . isDayPart ? proxy . maskDateValue . getDate ( ) . toString ( ) : proxy . defaultConstant [ 'day' ] . toString ( ) ;
422
422
break ;
423
- case 'dd' : result = proxy . isDayPart ? proxy . roundOff ( proxy . value . getDate ( ) , 2 ) : proxy . defaultConstant [ 'day' ] . toString ( ) ;
423
+ case 'dd' : result = proxy . isDayPart ? proxy . roundOff ( proxy . maskDateValue . getDate ( ) , 2 ) : proxy . defaultConstant [ 'day' ] . toString ( ) ;
424
424
break ;
425
425
case 'E' :
426
426
case 'EE' :
427
- case 'EEE' : result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysAbbreviated [ dayKeyAbbreviated [ proxy . value . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
427
+ case 'EEE' : result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysAbbreviated [ dayKeyAbbreviated [ proxy . maskDateValue . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
428
428
break ;
429
- case 'EEEE' : result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysWide [ dayKeyWide [ proxy . value . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
429
+ case 'EEEE' : result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysWide [ dayKeyWide [ proxy . maskDateValue . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
430
430
break ;
431
431
case 'EEEEE' :
432
- result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysNarrow [ dayKeyNarrow [ proxy . value . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
432
+ result = proxy . isDayPart && proxy . isMonthPart && proxy . isYearPart ? daysNarrow [ dayKeyNarrow [ proxy . maskDateValue . getDay ( ) ] ] . toString ( ) : proxy . defaultConstant [ 'dayOfTheWeek' ] . toString ( ) ;
433
433
break ;
434
- case 'M' : result = proxy . isMonthPart ? ( proxy . value . getMonth ( ) + 1 ) . toString ( ) : proxy . defaultConstant [ 'month' ] . toString ( ) ;
434
+ case 'M' : result = proxy . isMonthPart ? ( proxy . maskDateValue . getMonth ( ) + 1 ) . toString ( ) : proxy . defaultConstant [ 'month' ] . toString ( ) ;
435
435
break ;
436
- case 'MM' : result = proxy . isMonthPart ? proxy . roundOff ( proxy . value . getMonth ( ) + 1 , 2 ) : proxy . defaultConstant [ 'month' ] . toString ( ) ;
436
+ case 'MM' : result = proxy . isMonthPart ? proxy . roundOff ( proxy . maskDateValue . getMonth ( ) + 1 , 2 ) : proxy . defaultConstant [ 'month' ] . toString ( ) ;
437
437
break ;
438
- case 'MMM' : result = proxy . isMonthPart ? monthAbbreviated [ proxy . value . getMonth ( ) + 1 ] : proxy . defaultConstant [ 'month' ] . toString ( ) ;
438
+ case 'MMM' : result = proxy . isMonthPart ? monthAbbreviated [ proxy . maskDateValue . getMonth ( ) + 1 ] : proxy . defaultConstant [ 'month' ] . toString ( ) ;
439
439
break ;
440
- case 'MMMM' : result = proxy . isMonthPart ? monthWide [ proxy . value . getMonth ( ) + 1 ] : proxy . defaultConstant [ 'month' ] . toString ( ) ;
440
+ case 'MMMM' : result = proxy . isMonthPart ? monthWide [ proxy . maskDateValue . getMonth ( ) + 1 ] : proxy . defaultConstant [ 'month' ] . toString ( ) ;
441
441
break ;
442
- case 'yy' : result = proxy . isYearPart ? proxy . roundOff ( proxy . value . getFullYear ( ) % 100 , 2 ) : proxy . defaultConstant [ 'year' ] . toString ( ) ;
442
+ case 'yy' : result = proxy . isYearPart ? proxy . roundOff ( proxy . maskDateValue . getFullYear ( ) % 100 , 2 ) : proxy . defaultConstant [ 'year' ] . toString ( ) ;
443
443
if ( proxy . isYearPart ) {
444
- proxy . isNavigate = proxy . isShortYear = ( proxy . value . getFullYear ( ) % 100 ) . toString ( ) . length === 2 ;
444
+ proxy . isNavigate = proxy . isShortYear = ( proxy . maskDateValue . getFullYear ( ) % 100 ) . toString ( ) . length === 2 ;
445
445
}
446
446
break ;
447
447
case 'y' :
448
- case 'yyyy' : result = proxy . isYearPart ? proxy . roundOff ( proxy . value . getFullYear ( ) , 4 ) : proxy . defaultConstant [ 'year' ] . toString ( ) ;
448
+ case 'yyyy' : result = proxy . isYearPart ? proxy . roundOff ( proxy . maskDateValue . getFullYear ( ) , 4 ) : proxy . defaultConstant [ 'year' ] . toString ( ) ;
449
449
break ;
450
- case 'h' : result = proxy . isHourPart ? ( proxy . value . getHours ( ) % 12 || 12 ) . toString ( ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
450
+ case 'h' : result = proxy . isHourPart ? ( proxy . maskDateValue . getHours ( ) % 12 || 12 ) . toString ( ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
451
451
break ;
452
- case 'hh' : result = proxy . isHourPart ? proxy . roundOff ( proxy . value . getHours ( ) % 12 || 12 , 2 ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
452
+ case 'hh' : result = proxy . isHourPart ? proxy . roundOff ( proxy . maskDateValue . getHours ( ) % 12 || 12 , 2 ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
453
453
break ;
454
- case 'H' : result = proxy . isHourPart ? proxy . value . getHours ( ) . toString ( ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
454
+ case 'H' : result = proxy . isHourPart ? proxy . maskDateValue . getHours ( ) . toString ( ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
455
455
break ;
456
- case 'HH' : result = proxy . isHourPart ? proxy . roundOff ( proxy . value . getHours ( ) , 2 ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
456
+ case 'HH' : result = proxy . isHourPart ? proxy . roundOff ( proxy . maskDateValue . getHours ( ) , 2 ) : proxy . defaultConstant [ 'hour' ] . toString ( ) ;
457
457
break ;
458
- case 'm' : result = proxy . isMinutePart ? proxy . value . getMinutes ( ) . toString ( ) : proxy . defaultConstant [ 'minute' ] . toString ( ) ;
458
+ case 'm' : result = proxy . isMinutePart ? proxy . maskDateValue . getMinutes ( ) . toString ( ) : proxy . defaultConstant [ 'minute' ] . toString ( ) ;
459
459
break ;
460
- case 'mm' : result = proxy . isMinutePart ? proxy . roundOff ( proxy . value . getMinutes ( ) , 2 ) : proxy . defaultConstant [ 'minute' ] . toString ( ) ;
460
+ case 'mm' : result = proxy . isMinutePart ? proxy . roundOff ( proxy . maskDateValue . getMinutes ( ) , 2 ) : proxy . defaultConstant [ 'minute' ] . toString ( ) ;
461
461
break ;
462
- case 's' : result = proxy . isSecondsPart ? proxy . value . getSeconds ( ) . toString ( ) : proxy . defaultConstant [ 'second' ] . toString ( ) ;
462
+ case 's' : result = proxy . isSecondsPart ? proxy . maskDateValue . getSeconds ( ) . toString ( ) : proxy . defaultConstant [ 'second' ] . toString ( ) ;
463
463
break ;
464
- case 'ss' : result = proxy . isSecondsPart ? proxy . roundOff ( proxy . value . getSeconds ( ) , 2 ) : proxy . defaultConstant [ 'second' ] . toString ( ) ;
464
+ case 'ss' : result = proxy . isSecondsPart ? proxy . roundOff ( proxy . maskDateValue . getSeconds ( ) , 2 ) : proxy . defaultConstant [ 'second' ] . toString ( ) ;
465
465
break ;
466
- case 'f' : result = Math . floor ( proxy . value . getMilliseconds ( ) / 100 ) . toString ( ) ;
466
+ case 'f' : result = Math . floor ( proxy . maskDateValue . getMilliseconds ( ) / 100 ) . toString ( ) ;
467
467
break ;
468
- case 'ff' : milliseconds = proxy . value . getMilliseconds ( ) ;
469
- if ( proxy . value . getMilliseconds ( ) > 99 ) {
470
- milliseconds = Math . floor ( proxy . value . getMilliseconds ( ) / 10 ) ;
468
+ case 'ff' : milliseconds = proxy . maskDateValue . getMilliseconds ( ) ;
469
+ if ( proxy . maskDateValue . getMilliseconds ( ) > 99 ) {
470
+ milliseconds = Math . floor ( proxy . maskDateValue . getMilliseconds ( ) / 10 ) ;
471
471
}
472
472
result = proxy . roundOff ( milliseconds , 2 ) ;
473
473
break ;
474
- case 'fff' : result = proxy . roundOff ( proxy . value . getMilliseconds ( ) , 3 ) ;
474
+ case 'fff' : result = proxy . roundOff ( proxy . maskDateValue . getMilliseconds ( ) , 3 ) ;
475
475
break ;
476
476
case 'a' :
477
- case 'aa' : result = proxy . value . getHours ( ) < 12 ? periodString [ periodkeys [ 0 ] ] : periodString [ periodkeys [ 1 ] ] ;
477
+ case 'aa' : result = proxy . maskDateValue . getHours ( ) < 12 ? periodString [ periodkeys [ 0 ] ] : periodString [ periodkeys [ 1 ] ] ;
478
478
break ;
479
479
case 'z' :
480
480
case 'zz' :
@@ -484,7 +484,7 @@ export class MaskedDateTime {
484
484
format : formattext ,
485
485
type : 'dateTime' , skeleton : 'yMd' , calendar : proxy . parent . calendarMode
486
486
} ;
487
- result = proxy . parent . globalize . formatDate ( proxy . value , dateOptions ) ;
487
+ result = proxy . parent . globalize . formatDate ( proxy . maskDateValue , dateOptions ) ;
488
488
break ;
489
489
}
490
490
result = result !== undefined ? result : formattext . slice ( 1 , formattext . length - 1 ) ;
@@ -554,7 +554,7 @@ export class MaskedDateTime {
554
554
case 'M' :
555
555
this . isMonthPart = isSegment ;
556
556
if ( ! isSegment ) {
557
- this . value . setMonth ( 0 ) ;
557
+ this . maskDateValue . setMonth ( 0 ) ;
558
558
this . monthCharacter = '' ;
559
559
}
560
560
break ;
@@ -588,10 +588,10 @@ export class MaskedDateTime {
588
588
} else {
589
589
return ;
590
590
}
591
- let newDateValue : Date = new Date ( this . value . getFullYear ( ) , this . value . getMonth ( ) , this . value . getDate ( ) , this . value . getHours ( ) ,
592
- this . value . getMinutes ( ) , this . value . getSeconds ( ) ) ;
593
- this . previousDate = new Date ( this . value . getFullYear ( ) , this . value . getMonth ( ) , this . value . getDate ( ) , this . value . getHours ( ) ,
594
- this . value . getMinutes ( ) , this . value . getSeconds ( ) ) ;
591
+ let newDateValue : Date = new Date ( this . maskDateValue . getFullYear ( ) , this . maskDateValue . getMonth ( ) , this . maskDateValue . getDate ( ) , this . maskDateValue . getHours ( ) ,
592
+ this . maskDateValue . getMinutes ( ) , this . maskDateValue . getSeconds ( ) ) ;
593
+ this . previousDate = new Date ( this . maskDateValue . getFullYear ( ) , this . maskDateValue . getMonth ( ) , this . maskDateValue . getDate ( ) , this . maskDateValue . getHours ( ) ,
594
+ this . maskDateValue . getMinutes ( ) , this . maskDateValue . getSeconds ( ) ) ;
595
595
let incrementValue : number = isDecrement ? - 1 : 1 ;
596
596
switch ( formatText ) {
597
597
case 'd' : newDateValue . setDate ( newDateValue . getDate ( ) + incrementValue ) ;
@@ -631,7 +631,7 @@ export class MaskedDateTime {
631
631
default :
632
632
break ;
633
633
}
634
- this . value = newDateValue . getFullYear ( ) > 0 ? newDateValue : this . value ;
634
+ this . maskDateValue = newDateValue . getFullYear ( ) > 0 ? newDateValue : this . maskDateValue ;
635
635
if ( this . validCharacters . indexOf ( this . hiddenMask [ start ] ) !== - 1 ) {
636
636
this . handleDeletion ( this . hiddenMask [ start ] , true ) ;
637
637
}
0 commit comments