: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
/* Tidy up after a dialog display. */
_tidyDialog: function( inst ) {
inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
/* Close date picker if clicked elsewhere. */
_checkExternalClick: function( event ) {
if ( !$.datepicker._curInst ) {
var $target = $( event.target ),
inst = $.datepicker._getInst( $target[ 0 ] );
if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
$target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
!$target.hasClass( $.datepicker.markerClassName ) &&
!$target.closest( "." + $.datepicker._triggerClass ).length &&
$.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
$.datepicker._hideDatepicker();
/* Adjust one of the date sub-fields. */
_adjustDate: function( id, offset, period ) {
inst = this._getInst( target[ 0 ] );
if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
this._adjustInstDate( inst, offset, period );
this._updateDatepicker( inst );
/* Action for current link. */
_gotoToday: function( id ) {
inst = this._getInst( target[ 0 ] );
if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
this._notifyChange( inst );
this._adjustDate( target );
/* Action for selecting a new month/year. */
_selectMonthYear: function( id, select, period ) {
inst = this._getInst( target[ 0 ] );
inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
parseInt( select.options[ select.selectedIndex ].value, 10 );
this._notifyChange( inst );
this._adjustDate( target );
/* Action for selecting a day. */
_selectDay: function( id, month, year, td ) {
if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
inst = this._getInst( target[ 0 ] );
inst.selectedDay = inst.currentDay = parseInt( $( "a", td ).attr( "data-date" ) );
inst.selectedMonth = inst.currentMonth = month;
inst.selectedYear = inst.currentYear = year;
this._selectDate( id, this._formatDate( inst,
inst.currentDay, inst.currentMonth, inst.currentYear ) );
/* Erase the input field and hide the date picker. */
_clearDate: function( id ) {
this._selectDate( target, "" );
/* Update the input field with the selected date. */
_selectDate: function( id, dateStr ) {
inst = this._getInst( target[ 0 ] );
dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
inst.input.val( dateStr );
this._updateAlternate( inst );
onSelect = this._get( inst, "onSelect" );
onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
} else if ( inst.input ) {
inst.input.trigger( "change" ); // fire the change event
this._updateDatepicker( inst );
this._lastInput = inst.input[ 0 ];
if ( typeof( inst.input[ 0 ] ) !== "object" ) {
inst.input.trigger( "focus" ); // restore focus
/* Update any alternate field to synchronise with the main field. */
_updateAlternate: function( inst ) {
var altFormat, date, dateStr,
altField = this._get( inst, "altField" );
if ( altField ) { // update alternate field too
altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
date = this._getDate( inst );
dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
$( document ).find( altField ).val( dateStr );
/* Set as beforeShowDay function to prevent selection of weekends.
* @param date Date - the date to customise
* @return [boolean, string] - is this date selectable?, what is its CSS class?
noWeekends: function( date ) {
return [ ( day > 0 && day < 6 ), "" ];
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
* @param date Date - the date to get the week for
* @return number - the number of the week within the year that contains this date
iso8601Week: function( date ) {
checkDate = new Date( date.getTime() );
// Find Thursday of this week starting on Monday
checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
time = checkDate.getTime();
checkDate.setMonth( 0 ); // Compare with Jan 1
return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
/* Parse a string value into a date object.
* See formatDate below for the possible formats.
* @param format string - the expected format of the date
* @param value string - the date in the above format
* @param settings Object - attributes include:
* shortYearCutoff number - the cutoff year for determining the century (optional)
* dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
* dayNames string[7] - names of the days from Sunday (optional)
* monthNamesShort string[12] - abbreviated names of the months (optional)
* monthNames string[12] - names of the months (optional)
* @return Date - the extracted date value or null if value is blank
parseDate: function( format, value, settings ) {
if ( format == null || value == null ) {
throw "Invalid arguments";
value = ( typeof value === "object" ? value.toString() : value + "" );
shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
// Check whether a format character is doubled
lookAhead = function( match ) {
var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
// Extract a number from the string value
getNumber = function( match ) {
var isDoubled = lookAhead( match ),
size = ( match === "@" ? 14 : ( match === "!" ? 20 :
( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
minSize = ( match === "y" ? size : 1 ),
digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
num = value.substring( iValue ).match( digits );
throw "Missing number at position " + iValue;
iValue += num[ 0 ].length;
return parseInt( num[ 0 ], 10 );
// Extract a name from the string value and convert to an index
getName = function( match, shortNames, longNames ) {
names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
} ).sort( function( a, b ) {
return -( a[ 1 ].length - b[ 1 ].length );
$.each( names, function( i, pair ) {
if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
throw "Unknown name at position " + iValue;
// Confirm that a literal character matches the string value
checkLiteral = function() {
if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
throw "Unexpected literal at position " + iValue;
for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
switch ( format.charAt( iFormat ) ) {
getName( "D", dayNamesShort, dayNames );
month = getNumber( "m" );
month = getName( "M", monthNamesShort, monthNames );
date = new Date( getNumber( "@" ) );
year = date.getFullYear();
month = date.getMonth() + 1;
date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
year = date.getFullYear();
month = date.getMonth() + 1;
if ( lookAhead( "'" ) ) {
if ( iValue < value.length ) {
extra = value.substr( iValue );
if ( !/^\s+/.test( extra ) ) {
throw "Extra/unparsed characters found in date: " + extra;
year = new Date().getFullYear();
} else if ( year < 100 ) {
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
( year <= shortYearCutoff ? 0 : -100 );
dim = this._getDaysInMonth( year, month - 1 );
date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
throw "Invalid date"; // E.g. 31/02/00
/* Standard date formats. */
ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
RSS: "D, d M y", // RFC 822
W3C: "yy-mm-dd", // ISO 8601
_ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
/* Format a date object into a string value.
* The format can be combinations of the following:
* d - day of month (no leading zero)
* dd - day of month (two digit)
* o - day of year (no leading zeros)
* oo - day of year (three digit)
* m - month of year (no leading zero)
* mm - month of year (two digit)
* @ - Unix timestamp (ms since 01/01/1970)
* ! - Windows ticks (100ns since 01/01/0001)
* @param format string - the desired format of the date
* @param date Date - the date value to format
* @param settings Object - attributes include:
* dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
* dayNames string[7] - names of the days from Sunday (optional)
* monthNamesShort string[12] - abbreviated names of the months (optional)
* monthNames string[12] - names of the months (optional)
* @return string - the date in the above format
formatDate: function( format, date, settings ) {
dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
// Check whether a format character is doubled
lookAhead = function( match ) {
var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
// Format a number, with leading zero if necessary
formatNumber = function( match, value, len ) {
if ( lookAhead( match ) ) {
while ( num.length < len ) {
// Format a name, short or long as requested
formatName = function( match, value, shortNames, longNames ) {
return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
output += format.charAt( iFormat );
switch ( format.charAt( iFormat ) ) {
output += formatNumber( "d", date.getDate(), 2 );
output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
output += formatNumber( "o",
Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
output += formatNumber( "m", date.getMonth() + 1, 2 );
output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
output += ( lookAhead( "y" ) ? date.getFullYear() :
( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
output += date.getTime();
output += date.getTime() * 10000 + this._ticksTo1970;
if ( lookAhead( "'" ) ) {
output += format.charAt( iFormat );
/* Extract all possible characters from the date format. */
_possibleChars: function( format ) {
// Check whether a format character is doubled
lookAhead = function( match ) {
var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {