@@ -1544,10 +1544,8 @@ export class DateRangePicker extends CalendarBase {
15441544 if ( range . length > 1 ) {
15451545 this . invalidValueString = null ;
15461546 const dateOptions : object = { format : this . formatString , type : 'date' , skeleton : 'yMd' } ;
1547- const start : Date = this . globalize . parseDate ( this . getAmPmValue ( range [ 0 ] ) , dateOptions ) ;
1548- const end : Date = this . globalize . parseDate ( this . getAmPmValue ( range [ 1 ] ) , dateOptions ) ;
1549- const startDate : Date = this . getStartEndDate ( start , false , range , dateOptions ) ;
1550- const endDate : Date = this . getStartEndDate ( end , true , range , dateOptions ) ;
1547+ const startDate : Date = this . globalize . parseDate ( this . getAmPmValue ( range [ 0 ] ) . trim ( ) , dateOptions ) ;
1548+ const endDate : Date = this . globalize . parseDate ( this . getAmPmValue ( range [ 1 ] ) . trim ( ) , dateOptions ) ;
15511549 if ( ! isNullOrUndefined ( startDate ) && ! isNaN ( + startDate ) && ! isNullOrUndefined ( endDate ) && ! isNaN ( + endDate ) ) {
15521550 const prevStartVal : Date = this . startValue ;
15531551 this . startValue = startDate ;
@@ -1617,12 +1615,10 @@ export class DateRangePicker extends CalendarBase {
16171615 this . updateHiddenInput ( ) ;
16181616 }
16191617
1620- private getStartEndDate ( date : Date , isEnd : boolean , range : string [ ] , dateOptions : object ) : Date {
1621- if ( this . depth === 'Month' ) {
1622- return this . globalize . parseDate ( this . getAmPmValue ( range [ isEnd ? 1 : 0 ] ) . trim ( ) , dateOptions ) ;
1623- } else if ( this . depth === 'Year' && ! isNullOrUndefined ( date ) ) {
1618+ private getStartEndDate ( date : Date , isEnd : boolean ) : Date {
1619+ if ( this . currentView ( ) === 'Year' && ! isNullOrUndefined ( date ) ) {
16241620 return new Date ( date . getFullYear ( ) , date . getMonth ( ) + ( isEnd ? 1 : 0 ) , isEnd ? 0 : 1 ) ;
1625- } else if ( ! isNullOrUndefined ( date ) ) {
1621+ } else if ( this . currentView ( ) === 'Decade' && ! isNullOrUndefined ( date ) ) {
16261622 return new Date ( date . getFullYear ( ) , isEnd ? 11 : 0 , isEnd ? 31 : 1 ) ;
16271623 } else {
16281624 return null ;
@@ -2087,7 +2083,7 @@ export class DateRangePicker extends CalendarBase {
20872083 const isDisabledCell : boolean = ( ! ele . classList . contains ( DISABLED ) || ele . classList . contains ( DATEDISABLED ) ) ;
20882084 if ( ! ele . classList . contains ( WEEKNUMBER ) && isDisabledCell ) {
20892085 const eleDate : Date = this . getIdValue ( null , ele ) ;
2090- const startDateValue : Date = new Date ( + this . startValue ) ;
2086+ const startDateValue : Date = this . currentView ( ) === 'Month' ? new Date ( + this . startValue ) : this . getStartEndDate ( new Date ( + this . startValue ) , false ) ;
20912087 const eleDateValue : Date = new Date ( + eleDate ) ;
20922088 if ( eleDateValue . setHours ( 0 , 0 , 0 , 0 ) >= startDateValue . setHours ( 0 , 0 , 0 , 0 ) && + eleDate <= + currentDate ) {
20932089 addClass ( [ ele ] , RANGEHOVER ) ;
@@ -2126,9 +2122,11 @@ export class DateRangePicker extends CalendarBase {
21262122 const eleDate : Date = this . getIdValue ( null , ele ) ;
21272123 const eleDateValue : Date = this . getIdValue ( null , ele ) ;
21282124 if ( ! isNullOrUndefined ( this . endValue ) ) {
2125+ const eleStartDateValue : Date = this . currentView ( ) === 'Month' ? new Date ( + this . startValue ) : this . getStartEndDate ( new Date ( + this . startValue ) , false ) ;
2126+ const eleEndDateValue : Date = this . currentView ( ) === 'Month' ? new Date ( + this . endValue ) : this . getStartEndDate ( new Date ( + this . endValue ) , true ) ;
21292127 if ( this . currentView ( ) === this . depth &&
2130- + eleDateValue . setHours ( 0 , 0 , 0 , 0 ) >= + new Date ( + this . startValue ) . setHours ( 0 , 0 , 0 , 0 )
2131- && + eleDateValue . setHours ( 0 , 0 , 0 , 0 ) <= + new Date ( + this . endValue ) . setHours ( 0 , 0 , 0 , 0 ) &&
2128+ + eleDateValue . setHours ( 0 , 0 , 0 , 0 ) >= + eleStartDateValue . setHours ( 0 , 0 , 0 , 0 )
2129+ && + eleDateValue . setHours ( 0 , 0 , 0 , 0 ) <= + eleEndDateValue . setHours ( 0 , 0 , 0 , 0 ) &&
21322130 ! this . isSameStartEnd ( new Date ( + this . startValue ) , new Date ( + this . endValue ) ) &&
21332131 + new Date ( + this . startValue ) . setHours ( 0 , 0 , 0 , 0 ) >= + this . min
21342132 && + new Date ( + this . endValue ) . setHours ( 0 , 0 , 0 , 0 ) <= + this . max
@@ -2147,7 +2145,7 @@ export class DateRangePicker extends CalendarBase {
21472145 removeClass ( [ ele ] , [ RANGEHOVER ] ) ;
21482146 }
21492147 if ( ! ele . classList . contains ( OTHERMONTH ) ) {
2150- const startDateValue : Date = new Date ( + this . startValue ) ;
2148+ const startDateValue : Date = this . currentView ( ) === 'Month' ? new Date ( + this . startValue ) : this . getStartEndDate ( new Date ( + this . startValue ) , false ) ;
21512149 let eleDateValue : Date = new Date ( + eleDate ) ;
21522150 if ( this . currentView ( ) === this . depth &&
21532151 + eleDateValue . setHours ( 0 , 0 , 0 , 0 ) === + startDateValue . setHours ( 0 , 0 , 0 , 0 )
@@ -2158,7 +2156,7 @@ export class DateRangePicker extends CalendarBase {
21582156 addClass ( [ ele ] , [ STARTDATE , SELECTED ] ) ;
21592157 this . addSelectedAttributes ( ele , this . startValue , true ) ;
21602158 }
2161- const endDateValue : Date = new Date ( + this . endValue ) ;
2159+ const endDateValue : Date = this . currentView ( ) === 'Month' ? new Date ( + this . endValue ) : this . getStartEndDate ( new Date ( + this . endValue ) , true ) ;
21622160 if ( this . currentView ( ) === 'Year' ) {
21632161 eleDateValue = new Date ( eleDateValue . getFullYear ( ) , eleDateValue . getMonth ( ) + 1 , 0 ) ;
21642162 } else if ( this . currentView ( ) === 'Decade' ) {
@@ -2249,14 +2247,39 @@ export class DateRangePicker extends CalendarBase {
22492247 if ( event ) {
22502248 event . preventDefault ( ) ;
22512249 }
2252- const date : Date = isNullOrUndefined ( event ) ? this . getIdValue ( null , element )
2250+ let isValue : boolean ;
2251+ let startDateValue : Date ;
2252+ let endDateValue : Date ;
2253+ const value : string = ( < HTMLInputElement > this . inputElement ) . value ;
2254+ if ( ! isNullOrUndefined ( value ) && value . trim ( ) !== '' ) {
2255+ const range : string [ ] = value . split ( ' ' + this . separator + ' ' ) ;
2256+ if ( range . length > 1 && ( ( this . currentView ( ) === 'Year' && this . depth === 'Year' )
2257+ || ( this . currentView ( ) === 'Decade' && this . depth === 'Decade' ) ) ) {
2258+ const dateOptions : object = { format : this . formatString , type : 'date' , skeleton : 'yMd' } ;
2259+ startDateValue = this . globalize . parseDate ( this . getAmPmValue ( range [ 0 ] ) . trim ( ) , dateOptions ) ;
2260+ endDateValue = this . globalize . parseDate ( this . getAmPmValue ( range [ 1 ] ) . trim ( ) , dateOptions ) ;
2261+ isValue = true ;
2262+ }
2263+ }
2264+ let date : Date = isNullOrUndefined ( event ) ? this . getIdValue ( null , element )
22532265 : this . getIdValue ( event , null ) ;
2266+ if ( ! isNullOrUndefined ( this . startValue ) ) {
2267+ if ( this . currentView ( ) === 'Year' && this . depth === 'Year' ) {
2268+ date = new Date ( date . getFullYear ( ) , date . getMonth ( ) , this . startValue . getDate ( ) ) ;
2269+ } else if ( this . currentView ( ) === 'Decade' && this . depth === 'Decade' ) {
2270+ date = new Date ( date . getFullYear ( ) , this . startValue . getMonth ( ) , this . startValue . getDate ( ) ) ;
2271+ }
2272+ }
22542273 const y : number = date . getFullYear ( ) ;
22552274 const m : number = date . getMonth ( ) ;
2256- const firstDay : Date = new Date ( y , m , 1 ) ;
2257- const lastDay : Date = new Date ( y , m + 1 , 0 ) ;
2258- const firstMonth : Date = new Date ( y , 0 , 1 ) ;
2259- const lastMonth : Date = new Date ( y , 11 , 31 ) ;
2275+ const firstDay : Date = isValue ? new Date ( y , m , startDateValue . getDate ( ) , startDateValue . getHours ( ) , startDateValue . getMinutes ( ) ,
2276+ startDateValue . getSeconds ( ) ) : new Date ( y , m , 1 ) ;
2277+ const lastDay : Date = isValue ? new Date ( y , m , endDateValue . getDate ( ) , endDateValue . getHours ( ) , endDateValue . getMinutes ( ) ,
2278+ endDateValue . getSeconds ( ) ) : new Date ( y , m + 1 , 0 ) ;
2279+ const firstMonth : Date = isValue ? new Date ( y , startDateValue . getMonth ( ) , startDateValue . getDate ( ) , startDateValue . getHours ( ) ,
2280+ startDateValue . getMinutes ( ) , startDateValue . getSeconds ( ) ) : new Date ( y , 0 , 1 ) ;
2281+ const lastMonth : Date = isValue ? new Date ( y , endDateValue . getMonth ( ) , endDateValue . getDate ( ) , endDateValue . getHours ( ) ,
2282+ endDateValue . getMinutes ( ) , endDateValue . getSeconds ( ) ) : new Date ( y , 11 , 31 ) ;
22602283 if ( ! isNullOrUndefined ( this . endValue ) && ! isNullOrUndefined ( this . startValue ) ) {
22612284 if ( ! this . isMobile || this . isMobile && ! this . endButton . element . classList . contains ( ACTIVE ) ) {
22622285 this . removeSelection ( ) ;
0 commit comments