@@ -1406,7 +1406,7 @@ $.extend( Datepicker.prototype, {
14061406 break ;
14071407 case "o" :
14081408 output += formatNumber ( "o" ,
1409- Math . round ( ( new Date ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) ) . getTime ( ) - new Date ( date . getFullYear ( ) , 0 , 0 ) . getTime ( ) ) / 86400000 ) , 3 ) ;
1409+ Math . round ( ( this . _newDate ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) ) . getTime ( ) - this . _newDate ( date . getFullYear ( ) , 0 , 0 ) . getTime ( ) ) / 86400000 ) , 3 ) ;
14101410 break ;
14111411 case "m" :
14121412 output += formatNumber ( "m" , date . getMonth ( ) + 1 , 2 ) ;
@@ -1563,7 +1563,7 @@ $.extend( Datepicker.prototype, {
15631563 }
15641564 matches = pattern . exec ( offset ) ;
15651565 }
1566- return new Date ( year , month , day ) ;
1566+ return $ . datepicker . _newDate ( year , month , day ) ;
15671567 } ,
15681568 newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString ( date ) :
15691569 ( typeof date === "number" ? ( isNaN ( date ) ? defaultDate : offsetNumeric ( date ) ) : new Date ( date . getTime ( ) ) ) ) ) ;
@@ -1615,7 +1615,7 @@ $.extend( Datepicker.prototype, {
16151615 /* Retrieve the date(s) directly. */
16161616 _getDate : function ( inst ) {
16171617 var startDate = ( ! inst . currentYear || ( inst . input && inst . input . val ( ) === "" ) ? null :
1618- this . _daylightSavingAdjust ( new Date (
1618+ this . _daylightSavingAdjust ( this . _newDate (
16191619 inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ;
16201620 return startDate ;
16211621 } ,
@@ -1667,7 +1667,7 @@ $.extend( Datepicker.prototype, {
16671667 printDate , dRow , tbody , daySettings , otherMonth , unselectable ,
16681668 tempDate = new Date ( ) ,
16691669 today = this . _daylightSavingAdjust (
1670- new Date ( tempDate . getFullYear ( ) , tempDate . getMonth ( ) , tempDate . getDate ( ) ) ) , // clear time
1670+ this . _newDate ( tempDate . getFullYear ( ) , tempDate . getMonth ( ) , tempDate . getDate ( ) ) ) , // clear time
16711671 isRTL = this . _get ( inst , "isRTL" ) ,
16721672 showButtonPanel = this . _get ( inst , "showButtonPanel" ) ,
16731673 hideIfNoPrevNext = this . _get ( inst , "hideIfNoPrevNext" ) ,
@@ -1677,7 +1677,7 @@ $.extend( Datepicker.prototype, {
16771677 stepMonths = this . _get ( inst , "stepMonths" ) ,
16781678 isMultiMonth = ( numMonths [ 0 ] !== 1 || numMonths [ 1 ] !== 1 ) ,
16791679 currentDate = this . _daylightSavingAdjust ( ( ! inst . currentDay ? new Date ( 9999 , 9 , 9 ) :
1680- new Date ( inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ,
1680+ this . _newDate ( inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ,
16811681 minDate = this . _getMinMaxDate ( inst , "min" ) ,
16821682 maxDate = this . _getMinMaxDate ( inst , "max" ) ,
16831683 drawMonth = inst . drawMonth - showCurrentAtPos ,
@@ -1688,10 +1688,10 @@ $.extend( Datepicker.prototype, {
16881688 drawYear -- ;
16891689 }
16901690 if ( maxDate ) {
1691- maxDraw = this . _daylightSavingAdjust ( new Date ( maxDate . getFullYear ( ) ,
1691+ maxDraw = this . _daylightSavingAdjust ( this . _newDate ( maxDate . getFullYear ( ) ,
16921692 maxDate . getMonth ( ) - ( numMonths [ 0 ] * numMonths [ 1 ] ) + 1 , maxDate . getDate ( ) ) ) ;
16931693 maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw ) ;
1694- while ( this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth , 1 ) ) > maxDraw ) {
1694+ while ( this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth , 1 ) ) > maxDraw ) {
16951695 drawMonth -- ;
16961696 if ( drawMonth < 0 ) {
16971697 drawMonth = 11 ;
@@ -1704,7 +1704,7 @@ $.extend( Datepicker.prototype, {
17041704
17051705 prevText = this . _get ( inst , "prevText" ) ;
17061706 prevText = ( ! navigationAsDateFormat ? prevText : this . formatDate ( prevText ,
1707- this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth - stepMonths , 1 ) ) ,
1707+ this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth - stepMonths , 1 ) ) ,
17081708 this . _getFormatConfig ( inst ) ) ) ;
17091709
17101710 prev = ( this . _canAdjustMonth ( inst , - 1 , drawYear , drawMonth ) ?
@@ -1714,7 +1714,7 @@ $.extend( Datepicker.prototype, {
17141714
17151715 nextText = this . _get ( inst , "nextText" ) ;
17161716 nextText = ( ! navigationAsDateFormat ? nextText : this . formatDate ( nextText ,
1717- this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth + stepMonths , 1 ) ) ,
1717+ this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth + stepMonths , 1 ) ) ,
17181718 this . _getFormatConfig ( inst ) ) ) ;
17191719
17201720 next = ( this . _canAdjustMonth ( inst , + 1 , drawYear , drawMonth ) ?
@@ -1752,7 +1752,7 @@ $.extend( Datepicker.prototype, {
17521752 group = "" ;
17531753 this . maxRows = 4 ;
17541754 for ( col = 0 ; col < numMonths [ 1 ] ; col ++ ) {
1755- selectedDate = this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth , inst . selectedDay ) ) ;
1755+ selectedDate = this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth , inst . selectedDay ) ) ;
17561756 cornerClass = " ui-corner-all" ;
17571757 calender = "" ;
17581758 if ( isMultiMonth ) {
@@ -1790,7 +1790,7 @@ $.extend( Datepicker.prototype, {
17901790 curRows = Math . ceil ( ( leadDays + daysInMonth ) / 7 ) ; // calculate the number of rows to generate
17911791 numRows = ( isMultiMonth ? this . maxRows > curRows ? this . maxRows : curRows : curRows ) ; //If multiple months, use the higher number of rows (see #7043)
17921792 this . maxRows = numRows ;
1793- printDate = this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth , 1 - leadDays ) ) ;
1793+ printDate = this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth , 1 - leadDays ) ) ;
17941794 for ( dRow = 0 ; dRow < numRows ; dRow ++ ) { // create date picker rows
17951795 calender += "<tr>" ;
17961796 tbody = ( ! showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
@@ -1920,7 +1920,7 @@ $.extend( Datepicker.prototype, {
19201920 var year = inst . selectedYear + ( period === "Y" ? offset : 0 ) ,
19211921 month = inst . selectedMonth + ( period === "M" ? offset : 0 ) ,
19221922 day = Math . min ( inst . selectedDay , this . _getDaysInMonth ( year , month ) ) + ( period === "D" ? offset : 0 ) ,
1923- date = this . _restrictMinMax ( inst , this . _daylightSavingAdjust ( new Date ( year , month , day ) ) ) ;
1923+ date = this . _restrictMinMax ( inst , this . _daylightSavingAdjust ( this . _newDate ( year , month , day ) ) ) ;
19241924
19251925 inst . selectedDay = date . getDate ( ) ;
19261926 inst . drawMonth = inst . selectedMonth = date . getMonth ( ) ;
@@ -1960,18 +1960,18 @@ $.extend( Datepicker.prototype, {
19601960
19611961 /* Find the number of days in a given month. */
19621962 _getDaysInMonth : function ( year , month ) {
1963- return 32 - this . _daylightSavingAdjust ( new Date ( year , month , 32 ) ) . getDate ( ) ;
1963+ return 32 - this . _daylightSavingAdjust ( this . _newDate ( year , month , 32 ) ) . getDate ( ) ;
19641964 } ,
19651965
19661966 /* Find the day of the week of the first of a month. */
19671967 _getFirstDayOfMonth : function ( year , month ) {
1968- return new Date ( year , month , 1 ) . getDay ( ) ;
1968+ return this . _newDate ( year , month , 1 ) . getDay ( ) ;
19691969 } ,
19701970
19711971 /* Determines if we should allow a "next/prev" month display change. */
19721972 _canAdjustMonth : function ( inst , offset , curYear , curMonth ) {
19731973 var numMonths = this . _getNumberOfMonths ( inst ) ,
1974- date = this . _daylightSavingAdjust ( new Date ( curYear ,
1974+ date = this . _daylightSavingAdjust ( this . _newDate ( curYear ,
19751975 curMonth + ( offset < 0 ? offset : numMonths [ 0 ] * numMonths [ 1 ] ) , 1 ) ) ;
19761976
19771977 if ( offset < 0 ) {
@@ -2025,8 +2025,8 @@ $.extend( Datepicker.prototype, {
20252025 inst . currentYear = inst . selectedYear ;
20262026 }
20272027 var date = ( day ? ( typeof day === "object" ? day :
2028- this . _daylightSavingAdjust ( new Date ( year , month , day ) ) ) :
2029- this . _daylightSavingAdjust ( new Date ( inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ;
2028+ this . _daylightSavingAdjust ( this . _newDate ( year , month , day ) ) ) :
2029+ this . _daylightSavingAdjust ( this . _newDate ( inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ;
20302030 return this . formatDate ( this . _get ( inst , "dateFormat" ) , date , this . _getFormatConfig ( inst ) ) ;
20312031 } ,
20322032
0 commit comments