@@ -29,7 +29,7 @@ export class MaskedDateTime {
2929 private objectString : string [ ] ;
3030 private hiddenMask : string = '' ;
3131 private validCharacters : string = 'dMyhmHfasz' ;
32- private value : Date ;
32+ private maskDateValue : Date ;
3333 private previousValue : string ;
3434 private previousHiddenMask : string ;
3535 private isDayPart : boolean = false ;
@@ -53,13 +53,13 @@ export class MaskedDateTime {
5353 public constructor ( parent ? : IMaskedDateTime ) {
5454 this . parent = parent ;
5555 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 ( ) ) ;
6363 this . removeEventListener ( ) ;
6464 this . addEventListener ( ) ;
6565 }
@@ -155,7 +155,7 @@ export class MaskedDateTime {
155155 }
156156 }
157157 private setDynamicValue ( ) : void {
158- this . value = this . parent . value ;
158+ this . maskDateValue = this . parent . value ;
159159 this . isDayPart = this . isMonthPart = this . isYearPart = this . isHourPart = this . isMinutePart = this . isSecondsPart = true
160160 this . updateValue ( ) ;
161161 // this.parent.inputElement.selectionStart = start;
@@ -221,7 +221,7 @@ export class MaskedDateTime {
221221 let inputValue : string = this . parent . inputElement . value ;
222222 let previousVal : string = this . previousValue . substring ( 0 , start + this . previousValue . length - inputValue . length ) ;
223223 let newVal : string = inputValue . substring ( 0 , start ) ;
224- let newDateValue : Date = this . value ;
224+ let newDateValue : Date = this . maskDateValue ;
225225
226226 let maxDate : number = new Date ( newDateValue . getFullYear ( ) , newDateValue . getMonth ( ) + 1 , 0 ) . getDate ( ) ;
227227 if ( previousVal . indexOf ( newVal ) === 0 && ( newVal . length === 0 || this . previousHiddenMask [ newVal . length - 1 ] !== this . previousHiddenMask [ newVal . length ] ) ) {
@@ -247,7 +247,7 @@ export class MaskedDateTime {
247247 newDateValue . setDate ( date ) ;
248248 this . isNavigate = date . toString ( ) . length === 2 ;
249249 this . previousDate = new Date ( newDateValue . getFullYear ( ) , newDateValue . getMonth ( ) , newDateValue . getDate ( ) ) ;
250- if ( newDateValue . getMonth ( ) !== this . value . getMonth ( ) ) {
250+ if ( newDateValue . getMonth ( ) !== this . maskDateValue . getMonth ( ) ) {
251251 return ;
252252 }
253253 this . isDayPart = true ;
@@ -299,7 +299,7 @@ export class MaskedDateTime {
299299 if ( monthString [ i ] . toLowerCase ( ) . indexOf ( this . monthCharacter ) === 0 ) {
300300 newDateValue . setMonth ( i - 1 ) ;
301301 this . isMonthPart = true ;
302- this . value = newDateValue ;
302+ this . maskDateValue = newDateValue ;
303303 return ;
304304 }
305305 i ++ ;
@@ -386,7 +386,7 @@ export class MaskedDateTime {
386386 for ( let i : number = 0 ; this . periodCharacter . length > 0 ; i ++ ) {
387387 if ( ( periodString [ periodkeys [ 0 ] ] . toLowerCase ( ) . indexOf ( this . periodCharacter ) === 0 && newDateValue . getHours ( ) >= 12 ) || ( periodString [ periodkeys [ 1 ] ] . toLowerCase ( ) . indexOf ( this . periodCharacter ) === 0 && newDateValue . getHours ( ) < 12 ) ) {
388388 newDateValue . setHours ( ( newDateValue . getHours ( ) + 12 ) % 24 ) ;
389- this . value = newDateValue ;
389+ this . maskDateValue = newDateValue ;
390390 }
391391 this . periodCharacter = this . periodCharacter . substring ( 1 , this . periodCharacter . length ) ;
392392 // Object.values()
@@ -395,7 +395,7 @@ export class MaskedDateTime {
395395 default :
396396 break ;
397397 }
398- this . value = newDateValue ;
398+ this . maskDateValue = newDateValue ;
399399 }
400400
401401 private formatCheck ( ) : any {
@@ -418,63 +418,63 @@ export class MaskedDateTime {
418418 switch ( formattext ) {
419419 case 'ddd' :
420420 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 ( ) ;
422422 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 ( ) ;
424424 break ;
425425 case 'E' :
426426 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 ( ) ;
428428 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 ( ) ;
430430 break ;
431431 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 ( ) ;
433433 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 ( ) ;
435435 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 ( ) ;
437437 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 ( ) ;
439439 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 ( ) ;
441441 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 ( ) ;
443443 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 ;
445445 }
446446 break ;
447447 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 ( ) ;
449449 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 ( ) ;
451451 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 ( ) ;
453453 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 ( ) ;
455455 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 ( ) ;
457457 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 ( ) ;
459459 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 ( ) ;
461461 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 ( ) ;
463463 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 ( ) ;
465465 break ;
466- case 'f' : result = Math . floor ( proxy . value . getMilliseconds ( ) / 100 ) . toString ( ) ;
466+ case 'f' : result = Math . floor ( proxy . maskDateValue . getMilliseconds ( ) / 100 ) . toString ( ) ;
467467 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 ) ;
471471 }
472472 result = proxy . roundOff ( milliseconds , 2 ) ;
473473 break ;
474- case 'fff' : result = proxy . roundOff ( proxy . value . getMilliseconds ( ) , 3 ) ;
474+ case 'fff' : result = proxy . roundOff ( proxy . maskDateValue . getMilliseconds ( ) , 3 ) ;
475475 break ;
476476 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 ] ] ;
478478 break ;
479479 case 'z' :
480480 case 'zz' :
@@ -484,7 +484,7 @@ export class MaskedDateTime {
484484 format : formattext ,
485485 type : 'dateTime' , skeleton : 'yMd' , calendar : proxy . parent . calendarMode
486486 } ;
487- result = proxy . parent . globalize . formatDate ( proxy . value , dateOptions ) ;
487+ result = proxy . parent . globalize . formatDate ( proxy . maskDateValue , dateOptions ) ;
488488 break ;
489489 }
490490 result = result !== undefined ? result : formattext . slice ( 1 , formattext . length - 1 ) ;
@@ -554,7 +554,7 @@ export class MaskedDateTime {
554554 case 'M' :
555555 this . isMonthPart = isSegment ;
556556 if ( ! isSegment ) {
557- this . value . setMonth ( 0 ) ;
557+ this . maskDateValue . setMonth ( 0 ) ;
558558 this . monthCharacter = '' ;
559559 }
560560 break ;
@@ -588,10 +588,10 @@ export class MaskedDateTime {
588588 } else {
589589 return ;
590590 }
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 ( ) ) ;
595595 let incrementValue : number = isDecrement ? - 1 : 1 ;
596596 switch ( formatText ) {
597597 case 'd' : newDateValue . setDate ( newDateValue . getDate ( ) + incrementValue ) ;
@@ -631,7 +631,7 @@ export class MaskedDateTime {
631631 default :
632632 break ;
633633 }
634- this . value = newDateValue . getFullYear ( ) > 0 ? newDateValue : this . value ;
634+ this . maskDateValue = newDateValue . getFullYear ( ) > 0 ? newDateValue : this . maskDateValue ;
635635 if ( this . validCharacters . indexOf ( this . hiddenMask [ start ] ) !== - 1 ) {
636636 this . handleDeletion ( this . hiddenMask [ start ] , true ) ;
637637 }
0 commit comments