Skip to main content

Search and Top Navigation

#13651 closed bug (worksforme)

Opened July 15, 2015 03:26AM UTC

Closed July 15, 2015 03:30PM UTC

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)));''

...

Attachments (0)
Change History (2)

Changed July 15, 2015 03:19PM UTC by scottgonzalez comment:1

#13650 is a duplicate of this ticket.

Changed July 15, 2015 03:30PM UTC by scottgonzalez comment:2

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