@@ -1406,7 +1406,7 @@ $.extend( Datepicker.prototype, {
1406
1406
break ;
1407
1407
case "o" :
1408
1408
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 ) ;
1410
1410
break ;
1411
1411
case "m" :
1412
1412
output += formatNumber ( "m" , date . getMonth ( ) + 1 , 2 ) ;
@@ -1563,7 +1563,7 @@ $.extend( Datepicker.prototype, {
1563
1563
}
1564
1564
matches = pattern . exec ( offset ) ;
1565
1565
}
1566
- return new Date ( year , month , day ) ;
1566
+ return $ . datepicker . _newDate ( year , month , day ) ;
1567
1567
} ,
1568
1568
newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString ( date ) :
1569
1569
( typeof date === "number" ? ( isNaN ( date ) ? defaultDate : offsetNumeric ( date ) ) : new Date ( date . getTime ( ) ) ) ) ) ;
@@ -1615,7 +1615,7 @@ $.extend( Datepicker.prototype, {
1615
1615
/* Retrieve the date(s) directly. */
1616
1616
_getDate : function ( inst ) {
1617
1617
var startDate = ( ! inst . currentYear || ( inst . input && inst . input . val ( ) === "" ) ? null :
1618
- this . _daylightSavingAdjust ( new Date (
1618
+ this . _daylightSavingAdjust ( this . _newDate (
1619
1619
inst . currentYear , inst . currentMonth , inst . currentDay ) ) ) ;
1620
1620
return startDate ;
1621
1621
} ,
@@ -1667,7 +1667,7 @@ $.extend( Datepicker.prototype, {
1667
1667
printDate , dRow , tbody , daySettings , otherMonth , unselectable ,
1668
1668
tempDate = new Date ( ) ,
1669
1669
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
1671
1671
isRTL = this . _get ( inst , "isRTL" ) ,
1672
1672
showButtonPanel = this . _get ( inst , "showButtonPanel" ) ,
1673
1673
hideIfNoPrevNext = this . _get ( inst , "hideIfNoPrevNext" ) ,
@@ -1677,7 +1677,7 @@ $.extend( Datepicker.prototype, {
1677
1677
stepMonths = this . _get ( inst , "stepMonths" ) ,
1678
1678
isMultiMonth = ( numMonths [ 0 ] !== 1 || numMonths [ 1 ] !== 1 ) ,
1679
1679
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 ) ) ) ,
1681
1681
minDate = this . _getMinMaxDate ( inst , "min" ) ,
1682
1682
maxDate = this . _getMinMaxDate ( inst , "max" ) ,
1683
1683
drawMonth = inst . drawMonth - showCurrentAtPos ,
@@ -1688,10 +1688,10 @@ $.extend( Datepicker.prototype, {
1688
1688
drawYear -- ;
1689
1689
}
1690
1690
if ( maxDate ) {
1691
- maxDraw = this . _daylightSavingAdjust ( new Date ( maxDate . getFullYear ( ) ,
1691
+ maxDraw = this . _daylightSavingAdjust ( this . _newDate ( maxDate . getFullYear ( ) ,
1692
1692
maxDate . getMonth ( ) - ( numMonths [ 0 ] * numMonths [ 1 ] ) + 1 , maxDate . getDate ( ) ) ) ;
1693
1693
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 ) {
1695
1695
drawMonth -- ;
1696
1696
if ( drawMonth < 0 ) {
1697
1697
drawMonth = 11 ;
@@ -1704,7 +1704,7 @@ $.extend( Datepicker.prototype, {
1704
1704
1705
1705
prevText = this . _get ( inst , "prevText" ) ;
1706
1706
prevText = ( ! navigationAsDateFormat ? prevText : this . formatDate ( prevText ,
1707
- this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth - stepMonths , 1 ) ) ,
1707
+ this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth - stepMonths , 1 ) ) ,
1708
1708
this . _getFormatConfig ( inst ) ) ) ;
1709
1709
1710
1710
prev = ( this . _canAdjustMonth ( inst , - 1 , drawYear , drawMonth ) ?
@@ -1714,7 +1714,7 @@ $.extend( Datepicker.prototype, {
1714
1714
1715
1715
nextText = this . _get ( inst , "nextText" ) ;
1716
1716
nextText = ( ! navigationAsDateFormat ? nextText : this . formatDate ( nextText ,
1717
- this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth + stepMonths , 1 ) ) ,
1717
+ this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth + stepMonths , 1 ) ) ,
1718
1718
this . _getFormatConfig ( inst ) ) ) ;
1719
1719
1720
1720
next = ( this . _canAdjustMonth ( inst , + 1 , drawYear , drawMonth ) ?
@@ -1752,7 +1752,7 @@ $.extend( Datepicker.prototype, {
1752
1752
group = "" ;
1753
1753
this . maxRows = 4 ;
1754
1754
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 ) ) ;
1756
1756
cornerClass = " ui-corner-all" ;
1757
1757
calender = "" ;
1758
1758
if ( isMultiMonth ) {
@@ -1790,7 +1790,7 @@ $.extend( Datepicker.prototype, {
1790
1790
curRows = Math . ceil ( ( leadDays + daysInMonth ) / 7 ) ; // calculate the number of rows to generate
1791
1791
numRows = ( isMultiMonth ? this . maxRows > curRows ? this . maxRows : curRows : curRows ) ; //If multiple months, use the higher number of rows (see #7043)
1792
1792
this . maxRows = numRows ;
1793
- printDate = this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth , 1 - leadDays ) ) ;
1793
+ printDate = this . _daylightSavingAdjust ( this . _newDate ( drawYear , drawMonth , 1 - leadDays ) ) ;
1794
1794
for ( dRow = 0 ; dRow < numRows ; dRow ++ ) { // create date picker rows
1795
1795
calender += "<tr>" ;
1796
1796
tbody = ( ! showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
@@ -1920,7 +1920,7 @@ $.extend( Datepicker.prototype, {
1920
1920
var year = inst . selectedYear + ( period === "Y" ? offset : 0 ) ,
1921
1921
month = inst . selectedMonth + ( period === "M" ? offset : 0 ) ,
1922
1922
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 ) ) ) ;
1924
1924
1925
1925
inst . selectedDay = date . getDate ( ) ;
1926
1926
inst . drawMonth = inst . selectedMonth = date . getMonth ( ) ;
@@ -1960,18 +1960,18 @@ $.extend( Datepicker.prototype, {
1960
1960
1961
1961
/* Find the number of days in a given month. */
1962
1962
_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 ( ) ;
1964
1964
} ,
1965
1965
1966
1966
/* Find the day of the week of the first of a month. */
1967
1967
_getFirstDayOfMonth : function ( year , month ) {
1968
- return new Date ( year , month , 1 ) . getDay ( ) ;
1968
+ return this . _newDate ( year , month , 1 ) . getDay ( ) ;
1969
1969
} ,
1970
1970
1971
1971
/* Determines if we should allow a "next/prev" month display change. */
1972
1972
_canAdjustMonth : function ( inst , offset , curYear , curMonth ) {
1973
1973
var numMonths = this . _getNumberOfMonths ( inst ) ,
1974
- date = this . _daylightSavingAdjust ( new Date ( curYear ,
1974
+ date = this . _daylightSavingAdjust ( this . _newDate ( curYear ,
1975
1975
curMonth + ( offset < 0 ? offset : numMonths [ 0 ] * numMonths [ 1 ] ) , 1 ) ) ;
1976
1976
1977
1977
if ( offset < 0 ) {
@@ -2025,8 +2025,8 @@ $.extend( Datepicker.prototype, {
2025
2025
inst . currentYear = inst . selectedYear ;
2026
2026
}
2027
2027
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 ) ) ) ;
2030
2030
return this . formatDate ( this . _get ( inst , "dateFormat" ) , date , this . _getFormatConfig ( inst ) ) ;
2031
2031
} ,
2032
2032
0 commit comments