Oh no! Some styles failed to load. 😵 Please try reloading this page
Menu â–¾ â–´

#7 Dates not parsed properly

v1.0_(example)
closed-fixed
nobody
7
2014-08-17
2003-04-07
No

In the Calendar.prototype.parseDate function in
calendar.js, the date "09/04/2003" does not parse
properly with the format "dd/mm/y" or probably any
other format.

The reason is that the parseInt function being used is
not passing a radix as a second parameter so the 09
value is being interpreted as an octal value. The code
below is my modified snippet of the main loop that uses
the radix 10 to ensure we are using base 10 values:-

for (i = 0; i < a.length; ++i) {
if (b[i] == "D" || b[i] == "DD") {
continue;
}
if (b[i] == "d" || b[i] == "dd") {
d = parseInt(a[i], 10);
}
if (b[i] == "m" || b[i] == "mm") {
m = parseInt(a[i], 10) - 1;
}
if (b[i] == "y") {
y = parseInt(a[i], 10);
}
if (b[i] == "yy") {
y = parseInt(a[i], 10) + 1900;
}
if (b[i] == "M" || b[i] == "MM") {
for (j = 0; j < 12; ++j) {
if (Calendar._MN[j].substr(0,
a[i].length).toLowerCase() == a[i].toLowerCase()) { m =
j; break; }
}
}
}

This is from version 0.9.2.

Best Regards, Chris.

Discussion

  • Chris Melikian

    Chris Melikian - 2003-04-07
    • priority: 5 --> 7
     
  • Nobody/Anonymous

    Logged In: NO

    thank you chris. i was pulling my head with this bug.

     
  • Nobody/Anonymous

    Logged In: NO

    Chris, I've found this bug, I've resolved it (at your same way)
    and I wanted to signal it, but you've preceded me ;)

    More information on parseInt bug:
    http://www.breakingpar.com/bkp/home.nsf/Doc!
    OpenNavigator&U=87256B280015193F87256C85006A6604

    bye, Dario

     
  • Mihai Bazon

    Mihai Bazon - 2003-06-22
    • status: open --> open-fixed
     
  • Mihai Bazon

    Mihai Bazon - 2003-06-22
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.