@@ -74,8 +74,9 @@ function Datepicker() {
7474 gotoCurrent : false , // True if today link goes back to current selection instead
7575 changeMonth : false , // True if month can be selected directly, false if only prev/next
7676 changeYear : false , // True if year can be selected directly, false if only prev/next
77- yearRange : '-10:+10' , // Range of years to display in drop-down,
78- // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
77+ yearRange : 'c-10:c+10' , // Range of years to display in drop-down,
78+ // either relative to today's year (-nn:+nn), relative to currently displayed year
79+ // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
7980 showOtherMonths : false , // True to show dates in other months, false to leave blank
8081 selectOtherMonths : false , // True to allow selection of dates in other months, false for unselectable
8182 showWeek : false , // True to show week of the year, false to not show it
@@ -1511,18 +1512,15 @@ $.extend(Datepicker.prototype, {
15111512 else {
15121513 // determine range of years to display
15131514 var years = this . _get ( inst , 'yearRange' ) . split ( ':' ) ;
1514- var year = 0 ;
1515- var endYear = 0 ;
1516- if ( years . length != 2 ) {
1517- year = drawYear - 10 ;
1518- endYear = drawYear + 10 ;
1519- } else if ( years [ 0 ] . charAt ( 0 ) == '+' || years [ 0 ] . charAt ( 0 ) == '-' ) {
1520- year = drawYear + parseInt ( years [ 0 ] , 10 ) ;
1521- endYear = drawYear + parseInt ( years [ 1 ] , 10 ) ;
1522- } else {
1523- year = parseInt ( years [ 0 ] , 10 ) ;
1524- endYear = parseInt ( years [ 1 ] , 10 ) ;
1525- }
1515+ var thisYear = new Date ( ) . getFullYear ( ) ;
1516+ var determineYear = function ( value ) {
1517+ var year = ( value . match ( / c [ + - ] .* / ) ? drawYear + parseInt ( value . substring ( 1 ) , 10 ) :
1518+ ( value . match ( / [ + - ] .* / ) ? thisYear + parseInt ( value , 10 ) :
1519+ parseInt ( value , 10 ) ) ) ;
1520+ return ( isNaN ( year ) ? thisYear : year ) ;
1521+ } ;
1522+ var year = determineYear ( years [ 0 ] ) ;
1523+ var endYear = Math . max ( year , determineYear ( years [ 1 ] || '' ) ) ;
15261524 year = ( minDate ? Math . max ( year , minDate . getFullYear ( ) ) : year ) ;
15271525 endYear = ( maxDate ? Math . min ( endYear , maxDate . getFullYear ( ) ) : endYear ) ;
15281526 html += '<select class="ui-datepicker-year" ' +
0 commit comments