@@ -1544,10 +1544,8 @@ export class DateRangePicker extends CalendarBase {
1544
1544
if ( range . length > 1 ) {
1545
1545
this . invalidValueString = null ;
1546
1546
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 ) ;
1551
1549
if ( ! isNullOrUndefined ( startDate ) && ! isNaN ( + startDate ) && ! isNullOrUndefined ( endDate ) && ! isNaN ( + endDate ) ) {
1552
1550
const prevStartVal : Date = this . startValue ;
1553
1551
this . startValue = startDate ;
@@ -1617,12 +1615,10 @@ export class DateRangePicker extends CalendarBase {
1617
1615
this . updateHiddenInput ( ) ;
1618
1616
}
1619
1617
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 ) ) {
1624
1620
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 ) ) {
1626
1622
return new Date ( date . getFullYear ( ) , isEnd ? 11 : 0 , isEnd ? 31 : 1 ) ;
1627
1623
} else {
1628
1624
return null ;
@@ -2087,7 +2083,7 @@ export class DateRangePicker extends CalendarBase {
2087
2083
const isDisabledCell : boolean = ( ! ele . classList . contains ( DISABLED ) || ele . classList . contains ( DATEDISABLED ) ) ;
2088
2084
if ( ! ele . classList . contains ( WEEKNUMBER ) && isDisabledCell ) {
2089
2085
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 ) ;
2091
2087
const eleDateValue : Date = new Date ( + eleDate ) ;
2092
2088
if ( eleDateValue . setHours ( 0 , 0 , 0 , 0 ) >= startDateValue . setHours ( 0 , 0 , 0 , 0 ) && + eleDate <= + currentDate ) {
2093
2089
addClass ( [ ele ] , RANGEHOVER ) ;
@@ -2126,9 +2122,11 @@ export class DateRangePicker extends CalendarBase {
2126
2122
const eleDate : Date = this . getIdValue ( null , ele ) ;
2127
2123
const eleDateValue : Date = this . getIdValue ( null , ele ) ;
2128
2124
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 ) ;
2129
2127
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 ) &&
2132
2130
! this . isSameStartEnd ( new Date ( + this . startValue ) , new Date ( + this . endValue ) ) &&
2133
2131
+ new Date ( + this . startValue ) . setHours ( 0 , 0 , 0 , 0 ) >= + this . min
2134
2132
&& + new Date ( + this . endValue ) . setHours ( 0 , 0 , 0 , 0 ) <= + this . max
@@ -2147,7 +2145,7 @@ export class DateRangePicker extends CalendarBase {
2147
2145
removeClass ( [ ele ] , [ RANGEHOVER ] ) ;
2148
2146
}
2149
2147
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 ) ;
2151
2149
let eleDateValue : Date = new Date ( + eleDate ) ;
2152
2150
if ( this . currentView ( ) === this . depth &&
2153
2151
+ eleDateValue . setHours ( 0 , 0 , 0 , 0 ) === + startDateValue . setHours ( 0 , 0 , 0 , 0 )
@@ -2158,7 +2156,7 @@ export class DateRangePicker extends CalendarBase {
2158
2156
addClass ( [ ele ] , [ STARTDATE , SELECTED ] ) ;
2159
2157
this . addSelectedAttributes ( ele , this . startValue , true ) ;
2160
2158
}
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 ) ;
2162
2160
if ( this . currentView ( ) === 'Year' ) {
2163
2161
eleDateValue = new Date ( eleDateValue . getFullYear ( ) , eleDateValue . getMonth ( ) + 1 , 0 ) ;
2164
2162
} else if ( this . currentView ( ) === 'Decade' ) {
@@ -2249,14 +2247,39 @@ export class DateRangePicker extends CalendarBase {
2249
2247
if ( event ) {
2250
2248
event . preventDefault ( ) ;
2251
2249
}
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 )
2253
2265
: 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
+ }
2254
2273
const y : number = date . getFullYear ( ) ;
2255
2274
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 ) ;
2260
2283
if ( ! isNullOrUndefined ( this . endValue ) && ! isNullOrUndefined ( this . startValue ) ) {
2261
2284
if ( ! this . isMobile || this . isMobile && ! this . endButton . element . classList . contains ( ACTIVE ) ) {
2262
2285
this . removeSelection ( ) ;
0 commit comments