From: Tim Wood Date: Fri, 11 Jan 2013 19:40:27 +0000 (-0800) Subject: changing two digit year parsing cutoff to match strptime #468 X-Git-Tag: 2.0.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7483a75f857e4c8fe883fa1c4d15cbf3002b947;p=thirdparty%2Fmoment.git changing two digit year parsing cutoff to match strptime #468 --- diff --git a/moment.js b/moment.js index 1d9cbcf84..414fafdd3 100644 --- a/moment.js +++ b/moment.js @@ -627,7 +627,7 @@ break; // YEAR case 'YY' : - datePartArray[0] = ~~input + (~~input > 70 ? 1900 : 2000); + datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000); break; case 'YYYY' : case 'YYYYY' : diff --git a/test/moment/create.js b/test/moment/create.js index 2be29b53d..11d81d14b 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -204,9 +204,11 @@ exports.create = { }, "string with format - years" : function(test) { - test.expect(2); - test.equal(moment('71', 'YY').format('YYYY'), '1971', '71 > 1971'); - test.equal(moment('69', 'YY').format('YYYY'), '2069', '69 > 2069'); + test.expect(4); + test.equal(moment('67', 'YY').format('YYYY'), '2067', '67 > 2067'); + test.equal(moment('68', 'YY').format('YYYY'), '2068', '68 > 2068'); + test.equal(moment('69', 'YY').format('YYYY'), '1969', '69 > 1969'); + test.equal(moment('70', 'YY').format('YYYY'), '1970', '70 > 1970'); test.done(); },