Opened 4 years ago

Closed 4 years ago

#13651 closed bug (worksforme)

navigationAsDateFormat not working as expected

Reported by: JohnnyO63 Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.11.4
Keywords: Cc:
Blocked by: Blocking:

Description

When using datepicker and setting the default for navigationAsDateFormat the buttons next, prev, and current return the correct date part formatted with the current values of nextText, prevText, and currentText. This is instead of using the current value of dateFormat.

i.e. the current date is '07/14/2015', the currentText is defaulting to 'Today', and the dateFormat is defaulting to 'mm/dd/yy'. When navigationAsDateFormat is true, the text shown on the current button is 'T19615a15' as the function formatDate() is trying to use the string 'Today' as a dateFormat instead of 'mm/dd/yy'.

in jquery-ui.js in datePicker._generateHTML(inst) you will find the following;

...

prevText = this._get(inst, "prevText");
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), this._getFormatConfig(inst)));

...

nextText = this._get(inst, "nextText");
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), this._getFormatConfig(inst)));

...		

currentText = this._get(inst, "currentText");
gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
currentText = (!navigationAsDateFormat ? currentText : this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));''

...

It should be as follows;

...

prevText = this._get(inst, "prevText");
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(this._get(inst, "dateFormat"), this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), this._getFormatConfig(inst)));

...

nextText = this._get(inst, "nextText");
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(this._get(inst, "dateFormat"), this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), this._getFormatConfig(inst)));

...		

currentText = this._get(inst, "currentText");
gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
currentText = (!navigationAsDateFormat ? currentText : this.formatDate(this._get(inst, "dateFormat"), gotoDate, this._getFormatConfig(inst)));''

...

Change History (2)

comment:1 Changed 4 years ago by Scott González

#13650 is a duplicate of this ticket.

comment:2 Changed 4 years ago by Scott González

Resolution: worksforme
Status: newclosed

The documentation is pretty clear about this:

Whether the prevText and nextText options should be parsed as dates by the formatDate function, allowing them to display the target month names for example.

It is missing the fact that currentText is also affected, but the code should not change. I've filed an issue for the documentation: https://github.com/jquery/api.jqueryui.com/issues/273

Note: See TracTickets for help on using tickets.