Closed GoogleCodeExporter closed 9 years ago
Thanks for pointing out the bug. I've fixed the error and committed (revision
140)
the new code to SVN (http://www.datejs.com/svn/).
I changed the .toString function to the following...
case "yyyy":
var y = "000" + x.getFullYear();
return y.substring(y.length - 4);
case "yy":
return x.toString("yyyy").substring(2);
Here are the SVN commit log notes...
--------------------
2008-3-3 [geoffrey.mcgill]
1. Fixed .toString() bug where .toString would not return four characters if
the
year was less than 1000.
Example
// Old
console.log(Date.today().set({year: 10}).toString("yyyy"); // "10"
// New
console.log(Date.today().set({year: 10}).toString("yyyy"); // "0010"
The fix also corrected the same issue with .toString("yy") if the year was less than 10.
// Old
console.log(Date.today().set({year: 5}).toString("yy"); // "5"
// New
console.log(Date.today().set({year: 5}).toString("yy"); // "05"
--------------------
Hope this helps.
Original comment by geoff%co...@gtempaccount.com
on 4 Mar 2008 at 1:08
Original issue reported on code.google.com by
bobbyru...@gmail.com
on 4 Mar 2008 at 12:29Attachments: