]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
changing two digit year parsing cutoff to match strptime #468
authorTim Wood <washwithcare@gmail.com>
Fri, 11 Jan 2013 19:40:27 +0000 (11:40 -0800)
committerTim Wood <washwithcare@gmail.com>
Fri, 11 Jan 2013 19:40:27 +0000 (11:40 -0800)
moment.js
test/moment/create.js

index 1d9cbcf842c92e17267f8c4085b551691c0810b1..414fafdd3cccf9a9eafaf79aaaa5e0a5220def53 100644 (file)
--- a/moment.js
+++ b/moment.js
             break;
         // YEAR
         case 'YY' :
-            datePartArray[0] = ~~input + (~~input > 70 ? 1900 : 2000);
+            datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000);
             break;
         case 'YYYY' :
         case 'YYYYY' :
index 2be29b53d34c1e7c1df76bc434d36dc90f3586a1..11d81d14bac6f3b9ca1decbb4bc9687ebfea92d8 100644 (file)
@@ -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();
     },