Search and Top Navigation
#14977 closed bug (worksforme)
Opened May 28, 2016 08:00PM UTC
Closed May 28, 2016 08:25PM UTC
Last modified May 29, 2016 02:04AM UTC
Parse error, unexpected literal. parseDate fails to consider the format DD, for long name of day of week
Reported by: | JeffMatthews2 | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.datepicker | Version: | 1.11.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
JQ-UI Version: jquery-ui-1.11.4.js
Browser: Chrome 51
OS - Win 10
Occurs when you include a literal in the date format as follows:
dateFormat: "DD, MM d, yy'-'",
DD long day name (e.g., "Saturday") is not in the case/switch as a possible format.
parseDate: function (format, value, settings) { if (format == null || value == null) { throw "Invalid arguments"; } value = (type... for (iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) === "'" && !lookAhead("'")) { literal = false; } else { checkLiteral(); } } else { switch (format.charAt(iFormat)) { case "d": day = getNumber("d"); break; case "D": getName("D", dayNamesShort, dayNames); break; case "o": doy = getNumber("o"); break; case "m": month = getNumber("m"); break; case "M": month = getName("M", monthNamesShort, monthNames); break; case "y": year = getNumber("y"); break; case "@": date = new Date(getNumber("@")); year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); break; case "!": date = new Date((getNumber("!") - this._ticksTo1970) / 10000); year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); break; case "'": if (lookAhead("'")){ checkLiteral(); } else { literal = true; } break; default: checkLiteral(); } }
Attachments (0)
Change History (3)
Changed May 28, 2016 08:25PM UTC by comment:1
component: | ui.core → ui.datepicker |
---|---|
resolution: | → worksforme |
status: | new → closed |
version: | 1.11.3 → 1.11.4 |
Changed May 29, 2016 02:03AM UTC by comment:2
I'm sorry. You are correct. I spent a lot of time figuring out a simple oversight on my part.
I had the input value formatted in a way which caused the parsing error.
Notice the dash (-):
itemTemplate: function (value) { // This is display mask for the date to be used in rows. return new moment(value).format("dddd, MMMM D, YYYY - h:mm a");
The parsing error triggered when clicking on the input element to invoke the datePicker selector dropdown. I finally figured out it was reading the input's value and that " - " will not work from within an input. It was an unescaped literal.
The following change was required. Notice the escape brackets:
return new moment(value).format("dddd, MMMM D, YYYY [-] h:mm a");
After all that investigating, it turns out the input needs to be properly formatted so that the picker can parse it.
Changed May 29, 2016 02:04AM UTC by comment:3
By the way, thanks for setting up that jsbin for me. I played with it until I got it right. You were very helpful.
Works fine for me: http://jsbin.com/junodesofo/edit?html,js,output