Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#2729 closed defect (fixed) module, function problem with abbrev. month names

Reported by: guest Owned by: Adam Peller
Priority: high Milestone: 1.0
Component: Date Version: 0.4.2
Keywords: Cc:
Blocked By: Blocking:


I found something of a problem with the function when trying to parse a submitted value which had just been generated by the function. In other words, I took the default value generated by for a 'dateOnly', medium 'formatLength' date object and send it back to be parsed by It would seem that what comes out from as a localized default should be parsable by as a localized default. And this is true for the 'en' localization. When I try 'fr', it doesn't work, giving a debug message of --Could not parse month name: 'avr'.-- for avril (April) in French.

The debug message is telling in that it should be 'avr.' and is not getting the period at the end of the abbreviation. So I looked around in the function and found this:

case "M":

if (l > 2) {

if (!options.strict) {

v = v.replace(/./g, "");

v = v.toLowerCase();



The v = v.replace(/./g, ""); line is removing the period so that later on, it never matches. This was a problem for me since most of the values my users will submit are those generated earlier by my little calendar script via

The quick fix is to remove the above line, but I wouldn't presume to know why that line was there in the first place or what might be the best coarse of action to fix the problem. Without that line, everything works fine for me. As far as I can tell, the intent was to make the parse function less restrictive.

Here is the full case "M" of the function:

case "M":

if (l > 2) {

if (!options.strict) {

v = v.replace(/./g, "");

v = v.toLowerCase();

} var months = info+ widthList[l - 3?].concat(); for (var j = 0; j < months.length; j++) {

if (!options.strict) {

months[j] = months[j].toLowerCase();

} if (v == months[j]) {

result.setMonth(j); expected.month = j; break;


} if (j == months.length) {

dojo.debug(" Could not parse month name: '" + v + "'."); return null;


} else {

result.setMonth(v - 1); expected.month = v - 1;

} break;

I commented out the line in question. Different browsers obviously all worked the same and I am using the latest build (0.4.2) of dojo.

Thanks in advance

dojo user -> dwight

Change History (4)

comment:1 Changed 15 years ago by Adam Peller

Owner: changed from anonymous to Adam Peller

comment:2 Changed 15 years ago by Adam Peller

Component: GeneralDate
Milestone: 1.0
Type: enhancementdefect

comment:3 Changed 15 years ago by Adam Peller

Resolution: fixed
Status: newclosed

(In [8725]) Replace for loops with dojo.forEach to reduce code. Fix non-strict comparison for month parsing. Fixes #2729

comment:4 Changed 15 years ago by Adam Peller

Resolution: fixed

(In [8748]) Fixes IE regression. Fixes #2729

Note: See TracTickets for help on using tickets.