From 9ea4e859bd865b6f2c4c9ac9e06b76365cc39ade Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Wed, 1 Oct 2014 00:43:26 -0700 Subject: [PATCH] Add ordial parse tests for all locales --- test/locale/af.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ar-ma.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ar-sa.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ar.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/az.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/be.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/bg.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/bn.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/bo.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/br.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/bs.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ca.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/cs.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/cv.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/cy.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/da.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/de-at.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/de.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/el.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/en-au.js | 31 +++++++++++++++++++++++++++++++ test/locale/en-ca.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/en-gb.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/en.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/eo.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/es.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/et.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/eu.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/fa.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/fi.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/fo.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/fr-ca.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/fr.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/gl.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/he.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/hi.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/hr.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/hu.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/hy-am.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/id.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/is.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/it.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ja.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ka.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/km.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ko.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/lb.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/lt.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/lv.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/mk.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ml.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/mr.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ms-my.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/my.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/nb.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ne.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/nl.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/nn.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/pl.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/pt-br.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/pt.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ro.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ru.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sk.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sl.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sq.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sr-cyrl.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sr.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/sv.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/ta.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/th.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/tl-ph.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/tr.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/tzm-latn.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/tzm.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/uk.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/uz.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/vi.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/zh-cn.js | 39 +++++++++++++++++++++++++++++++++++++++ test/locale/zh-tw.js | 39 +++++++++++++++++++++++++++++++++++++++ 79 files changed, 3073 insertions(+) diff --git a/test/locale/af.js b/test/locale/af.js index 3ff59de4d..f00bdcab2 100644 --- a/test/locale/af.js +++ b/test/locale/af.js @@ -314,6 +314,45 @@ exports['locale:af'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ar-ma.js b/test/locale/ar-ma.js index c6b80710c..ba5547f87 100644 --- a/test/locale/ar-ma.js +++ b/test/locale/ar-ma.js @@ -309,6 +309,45 @@ exports['locale:ar-ma'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ar-sa.js b/test/locale/ar-sa.js index 8c7247e24..fc48e2b51 100644 --- a/test/locale/ar-sa.js +++ b/test/locale/ar-sa.js @@ -351,6 +351,45 @@ exports['locale:ar-sa'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ar.js b/test/locale/ar.js index 035c0451a..5ca4197e9 100644 --- a/test/locale/ar.js +++ b/test/locale/ar.js @@ -329,6 +329,45 @@ exports['locale:ar'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/az.js b/test/locale/az.js index aa0138d6a..f0d7e7744 100644 --- a/test/locale/az.js +++ b/test/locale/az.js @@ -360,6 +360,45 @@ exports['locale:az'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-nci', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-üncü', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/be.js b/test/locale/be.js index e894a0744..458aa352f 100644 --- a/test/locale/be.js +++ b/test/locale/be.js @@ -372,6 +372,45 @@ exports['locale:be'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-і', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-і', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } diff --git a/test/locale/bg.js b/test/locale/bg.js index e619caa5f..d553958e6 100644 --- a/test/locale/bg.js +++ b/test/locale/bg.js @@ -328,6 +328,45 @@ exports['locale:bg'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/bn.js b/test/locale/bn.js index ffaceaaae..ad6f7c952 100644 --- a/test/locale/bn.js +++ b/test/locale/bn.js @@ -369,6 +369,45 @@ exports['locale:bn'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '২ ০২ ২', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '৩ ০৩ ৩', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/bo.js b/test/locale/bo.js index 1b2ea1332..cbddc0f08 100644 --- a/test/locale/bo.js +++ b/test/locale/bo.js @@ -332,6 +332,45 @@ exports['locale:bo'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '༢ ༠༢ ༢', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '༣ ༠༣ ༣', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/br.js b/test/locale/br.js index ec2db5b24..3bbad4ff6 100644 --- a/test/locale/br.js +++ b/test/locale/br.js @@ -254,5 +254,44 @@ exports['locale:br'] = { test.equal(start.from(moment([2007, 1, 28]).add({y: 148}), true), '148 vloaz', 'mutation 148 years'); test.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), '261 bloaz', 'mutation 261 years'); test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } + test.done(); } }; diff --git a/test/locale/bs.js b/test/locale/bs.js index 754382ebb..217b1f525 100644 --- a/test/locale/bs.js +++ b/test/locale/bs.js @@ -347,6 +347,45 @@ exports['locale:bs'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ca.js b/test/locale/ca.js index 99242d79a..92c4ff7d2 100644 --- a/test/locale/ca.js +++ b/test/locale/ca.js @@ -282,6 +282,45 @@ exports['locale:ca'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/cs.js b/test/locale/cs.js index 1c76dfa7a..91d1b67fd 100644 --- a/test/locale/cs.js +++ b/test/locale/cs.js @@ -403,6 +403,45 @@ exports['locale:cs'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/cv.js b/test/locale/cv.js index aa804948a..a0ec88089 100644 --- a/test/locale/cv.js +++ b/test/locale/cv.js @@ -316,6 +316,45 @@ exports['locale:cv'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-мĕш', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мĕш', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/cy.js b/test/locale/cy.js index a8a0687c5..ae8abde37 100644 --- a/test/locale/cy.js +++ b/test/locale/cy.js @@ -311,6 +311,45 @@ exports['locale:cy'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2il', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2il', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/da.js b/test/locale/da.js index 39c4620b6..231011bc6 100644 --- a/test/locale/da.js +++ b/test/locale/da.js @@ -260,6 +260,45 @@ exports['locale:da'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/de-at.js b/test/locale/de-at.js index eb27d77cf..f049098cb 100644 --- a/test/locale/de-at.js +++ b/test/locale/de-at.js @@ -346,6 +346,45 @@ exports['locale:de-at'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/de.js b/test/locale/de.js index 785699fa7..a4f776890 100644 --- a/test/locale/de.js +++ b/test/locale/de.js @@ -309,6 +309,45 @@ exports['locale:de'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/el.js b/test/locale/el.js index 541132a96..db4fa601c 100644 --- a/test/locale/el.js +++ b/test/locale/el.js @@ -373,6 +373,45 @@ exports['locale:el'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2η', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/en-au.js b/test/locale/en-au.js index 785e0fe4d..bf32f2837 100644 --- a/test/locale/en-au.js +++ b/test/locale/en-au.js @@ -315,6 +315,37 @@ exports['locale:en-au'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testStr; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D'); + test.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testStr; + for (i = 1; i <= 31; ++i) { + testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D'); + test.equal(testStr, '2014 01 ' + i, + 'lenient ordinal parsing of number ' + i); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do'); + testMoment = moment(ordinalStr, 'YYYY MMM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } + }; diff --git a/test/locale/en-ca.js b/test/locale/en-ca.js index 0bf45e8e2..25a347ec4 100644 --- a/test/locale/en-ca.js +++ b/test/locale/en-ca.js @@ -332,6 +332,45 @@ exports['locale:en-ca'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/en-gb.js b/test/locale/en-gb.js index 3d528329c..c68212981 100644 --- a/test/locale/en-gb.js +++ b/test/locale/en-gb.js @@ -315,6 +315,45 @@ exports['locale:en-gb'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/en.js b/test/locale/en.js index 073db5fdf..ae8ed5993 100644 --- a/test/locale/en.js +++ b/test/locale/en.js @@ -333,6 +333,45 @@ exports['locale:en'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/eo.js b/test/locale/eo.js index 051340fc9..ffe575492 100644 --- a/test/locale/eo.js +++ b/test/locale/eo.js @@ -316,6 +316,45 @@ exports['locale:eo'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2a', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/es.js b/test/locale/es.js index cadf33df4..e12f0e982 100644 --- a/test/locale/es.js +++ b/test/locale/es.js @@ -318,6 +318,45 @@ exports['locale:es'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/et.js b/test/locale/et.js index cb88716ba..ccbfe3170 100644 --- a/test/locale/et.js +++ b/test/locale/et.js @@ -338,6 +338,45 @@ exports['locale:et'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/eu.js b/test/locale/eu.js index 17e927a03..a7109b51f 100644 --- a/test/locale/eu.js +++ b/test/locale/eu.js @@ -313,6 +313,45 @@ exports['locale:eu'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/fa.js b/test/locale/fa.js index 494a276b0..4c28ad684 100644 --- a/test/locale/fa.js +++ b/test/locale/fa.js @@ -302,6 +302,45 @@ exports['locale:fa'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '۲ ۰۲ ۲م', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/fi.js b/test/locale/fi.js index 0d4730513..6e440d18d 100644 --- a/test/locale/fi.js +++ b/test/locale/fi.js @@ -314,6 +314,45 @@ exports['locale:fi'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/fo.js b/test/locale/fo.js index 57ec1ec60..501d6a695 100644 --- a/test/locale/fo.js +++ b/test/locale/fo.js @@ -260,6 +260,45 @@ exports['locale:fo'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/fr-ca.js b/test/locale/fr-ca.js index f5056f1f3..fbd37481f 100644 --- a/test/locale/fr-ca.js +++ b/test/locale/fr-ca.js @@ -327,6 +327,45 @@ exports['locale:fr-ca'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/fr.js b/test/locale/fr.js index 859870ca2..b9c140d17 100644 --- a/test/locale/fr.js +++ b/test/locale/fr.js @@ -311,6 +311,45 @@ exports['locale:fr'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/gl.js b/test/locale/gl.js index f3bb0fdf8..decb7f9b8 100644 --- a/test/locale/gl.js +++ b/test/locale/gl.js @@ -291,6 +291,45 @@ exports['locale:gl'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2º', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3º', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/he.js b/test/locale/he.js index 11c145547..1d7adb21f 100644 --- a/test/locale/he.js +++ b/test/locale/he.js @@ -276,6 +276,45 @@ exports['locale:he'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/hi.js b/test/locale/hi.js index d0c66f889..1ef499fd7 100644 --- a/test/locale/hi.js +++ b/test/locale/hi.js @@ -332,6 +332,45 @@ exports['locale:hi'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/hr.js b/test/locale/hr.js index 2a7b11719..eaa296544 100644 --- a/test/locale/hr.js +++ b/test/locale/hr.js @@ -347,6 +347,45 @@ exports['locale:hr'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/hu.js b/test/locale/hu.js index b85125152..003642c3e 100644 --- a/test/locale/hu.js +++ b/test/locale/hu.js @@ -330,6 +330,45 @@ exports['locale:hu'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/hy-am.js b/test/locale/hy-am.js index 4fd1eb6e5..2ee58285d 100644 --- a/test/locale/hy-am.js +++ b/test/locale/hy-am.js @@ -390,6 +390,45 @@ exports['locale:hy-am'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-րդ', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-րդ', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } diff --git a/test/locale/id.js b/test/locale/id.js index 95597ca23..f79d23480 100644 --- a/test/locale/id.js +++ b/test/locale/id.js @@ -275,6 +275,45 @@ exports['locale:id'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/is.js b/test/locale/is.js index 14ac9a36e..0dd3265a1 100644 --- a/test/locale/is.js +++ b/test/locale/is.js @@ -321,6 +321,45 @@ exports['locale:is'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/it.js b/test/locale/it.js index 20ec2ffaf..43029f22c 100644 --- a/test/locale/it.js +++ b/test/locale/it.js @@ -308,6 +308,45 @@ exports['locale:it'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ja.js b/test/locale/ja.js index 454e6b9e7..406ccbc06 100644 --- a/test/locale/ja.js +++ b/test/locale/ja.js @@ -275,6 +275,45 @@ exports['locale:ja'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ka.js b/test/locale/ka.js index b037f2b9c..707eff904 100644 --- a/test/locale/ka.js +++ b/test/locale/ka.js @@ -331,6 +331,45 @@ exports['locale:ka'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 მე-2', 'იან 8 2012 უნდა იყოს კვირა 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 მე-3', 'იან 9 2012 უნდა იყოს კვირა 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/km.js b/test/locale/km.js index f317cfd88..49fd547ca 100644 --- a/test/locale/km.js +++ b/test/locale/km.js @@ -342,6 +342,45 @@ exports['locale:km'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ko.js b/test/locale/ko.js index e489ce7b9..4c20838a5 100644 --- a/test/locale/ko.js +++ b/test/locale/ko.js @@ -355,6 +355,45 @@ exports['locale:ko'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2일', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3일', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/lb.js b/test/locale/lb.js index 2f80545b2..40f8be694 100644 --- a/test/locale/lb.js +++ b/test/locale/lb.js @@ -160,5 +160,44 @@ exports['locale:lb'] = { test.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days end of day'); } test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } + test.done(); } }; diff --git a/test/locale/lt.js b/test/locale/lt.js index 091fdf3fd..0d7f4b7d0 100644 --- a/test/locale/lt.js +++ b/test/locale/lt.js @@ -331,6 +331,45 @@ exports['locale:lt'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2-oji', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2-oji', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } diff --git a/test/locale/lv.js b/test/locale/lv.js index b0db7874a..de8f5ff70 100644 --- a/test/locale/lv.js +++ b/test/locale/lv.js @@ -313,6 +313,45 @@ exports['locale:lv'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/mk.js b/test/locale/mk.js index 0131256ee..4a5be5c29 100644 --- a/test/locale/mk.js +++ b/test/locale/mk.js @@ -328,6 +328,45 @@ exports['locale:mk'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ml.js b/test/locale/ml.js index 1307094e1..2cd6cc454 100644 --- a/test/locale/ml.js +++ b/test/locale/ml.js @@ -332,6 +332,45 @@ exports['locale:ml'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/mr.js b/test/locale/mr.js index bc946b811..e58a19fa5 100644 --- a/test/locale/mr.js +++ b/test/locale/mr.js @@ -332,6 +332,45 @@ exports['locale:mr'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ms-my.js b/test/locale/ms-my.js index 822e378db..3ef0551f8 100644 --- a/test/locale/ms-my.js +++ b/test/locale/ms-my.js @@ -331,6 +331,45 @@ exports['locale:ms-my'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 sepatutnya minggu 3'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/my.js b/test/locale/my.js index a1488902e..10227f3e6 100644 --- a/test/locale/my.js +++ b/test/locale/my.js @@ -435,6 +435,45 @@ exports['locale:my'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } diff --git a/test/locale/nb.js b/test/locale/nb.js index 2d9768c0d..79063281c 100644 --- a/test/locale/nb.js +++ b/test/locale/nb.js @@ -314,6 +314,45 @@ exports['locale:nb'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ne.js b/test/locale/ne.js index 211344526..2fcb13faf 100644 --- a/test/locale/ne.js +++ b/test/locale/ne.js @@ -331,6 +331,45 @@ exports['locale:ne'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '३ ०३ ३', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/nl.js b/test/locale/nl.js index 60eed0a50..594af3e2a 100644 --- a/test/locale/nl.js +++ b/test/locale/nl.js @@ -321,6 +321,45 @@ exports['locale:nl'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/nn.js b/test/locale/nn.js index 0925c3f9e..6ba34a588 100644 --- a/test/locale/nn.js +++ b/test/locale/nn.js @@ -313,6 +313,45 @@ exports['locale:nn'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/pl.js b/test/locale/pl.js index 279ed7f22..e8d19b8c4 100644 --- a/test/locale/pl.js +++ b/test/locale/pl.js @@ -335,6 +335,45 @@ exports['locale:pl'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/pt-br.js b/test/locale/pt-br.js index 3bf5615b9..7a55d517c 100644 --- a/test/locale/pt-br.js +++ b/test/locale/pt-br.js @@ -312,6 +312,45 @@ exports['locale:pt-br'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2º', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3º', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/pt.js b/test/locale/pt.js index 61b4165b4..08144e8a0 100644 --- a/test/locale/pt.js +++ b/test/locale/pt.js @@ -309,6 +309,45 @@ exports['locale:pt'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ro.js b/test/locale/ro.js index 262c3e114..718f5c3a3 100644 --- a/test/locale/ro.js +++ b/test/locale/ro.js @@ -322,6 +322,45 @@ exports['locale:ro'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ru.js b/test/locale/ru.js index 4d5e86e34..602a6e44c 100644 --- a/test/locale/ru.js +++ b/test/locale/ru.js @@ -404,6 +404,45 @@ exports['locale:ru'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-я', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-я', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sk.js b/test/locale/sk.js index bafe2f52c..4b9061618 100644 --- a/test/locale/sk.js +++ b/test/locale/sk.js @@ -403,6 +403,45 @@ exports['locale:sk'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sl.js b/test/locale/sl.js index 9283dadbb..6d4530f5b 100644 --- a/test/locale/sl.js +++ b/test/locale/sl.js @@ -346,6 +346,45 @@ exports['locale:sl'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sq.js b/test/locale/sq.js index 969c5af98..27662df81 100644 --- a/test/locale/sq.js +++ b/test/locale/sq.js @@ -339,6 +339,45 @@ exports['locale:sq'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sr-cyrl.js b/test/locale/sr-cyrl.js index d42129ec3..a58742382 100644 --- a/test/locale/sr-cyrl.js +++ b/test/locale/sr-cyrl.js @@ -349,6 +349,45 @@ exports['locale:sr-cyrl'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sr.js b/test/locale/sr.js index d2ac31355..738999860 100644 --- a/test/locale/sr.js +++ b/test/locale/sr.js @@ -349,6 +349,45 @@ exports['locale:sr'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/sv.js b/test/locale/sv.js index 3135b79ac..9e93f8d4f 100644 --- a/test/locale/sv.js +++ b/test/locale/sv.js @@ -313,6 +313,45 @@ exports['locale:sv'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2a', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/ta.js b/test/locale/ta.js index c95615ec6..92149e3c8 100644 --- a/test/locale/ta.js +++ b/test/locale/ta.js @@ -319,5 +319,44 @@ exports['locale:ta'] = { test.equal(moment([2011, 2, 23, 19, 30]).format('a'), ' மாலை', 'late evening'); test.equal(moment([2011, 2, 23, 21, 20]).format('a'), ' இரவு', 'night'); test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } + test.done(); } }; diff --git a/test/locale/th.js b/test/locale/th.js index 85671e03c..40246bfed 100644 --- a/test/locale/th.js +++ b/test/locale/th.js @@ -275,6 +275,45 @@ exports['locale:th'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/tl-ph.js b/test/locale/tl-ph.js index 4d8a82b77..3eef96551 100644 --- a/test/locale/tl-ph.js +++ b/test/locale/tl-ph.js @@ -311,6 +311,45 @@ exports['locale:tl-ph'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/tr.js b/test/locale/tr.js index dddf69ca7..ac999348e 100644 --- a/test/locale/tr.js +++ b/test/locale/tr.js @@ -325,6 +325,45 @@ exports['locale:tr'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2\'nci', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/tzm-latn.js b/test/locale/tzm-latn.js index 5978217f0..4de37018e 100644 --- a/test/locale/tzm-latn.js +++ b/test/locale/tzm-latn.js @@ -310,6 +310,45 @@ exports['locale:tzm-latn'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/tzm.js b/test/locale/tzm.js index 8a65e6d5c..24af9a8b4 100644 --- a/test/locale/tzm.js +++ b/test/locale/tzm.js @@ -310,6 +310,45 @@ exports['locale:tzm'] = { test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/uk.js b/test/locale/uk.js index b9d5a9ce4..dcc1222ae 100644 --- a/test/locale/uk.js +++ b/test/locale/uk.js @@ -348,6 +348,45 @@ exports['locale:uk'] = { test.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-й', 'Jan 8 2012 should be week 2'); test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-й', 'Jan 9 2012 should be week 3'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/uz.js b/test/locale/uz.js index df13ce901..e48dde1ba 100644 --- a/test/locale/uz.js +++ b/test/locale/uz.js @@ -315,6 +315,45 @@ exports['locale:uz'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/vi.js b/test/locale/vi.js index fc642d8a4..206b86998 100644 --- a/test/locale/vi.js +++ b/test/locale/vi.js @@ -333,6 +333,45 @@ exports['locale:vi'] = { test.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/zh-cn.js b/test/locale/zh-cn.js index 03d3c32fa..0663974e9 100644 --- a/test/locale/zh-cn.js +++ b/test/locale/zh-cn.js @@ -307,6 +307,45 @@ exports['locale:zh-cn'] = { test.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1周', 'Jan 7 2012 应该是第 1周'); test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2周', 'Jan 14 2012 应该是第 2周'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; diff --git a/test/locale/zh-tw.js b/test/locale/zh-tw.js index 966a0d4bf..a9d9efdf8 100644 --- a/test/locale/zh-tw.js +++ b/test/locale/zh-tw.js @@ -305,6 +305,45 @@ exports['locale:zh-tw'] = { test.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2週', 'Jan 14 2012 應該是第 2週'); test.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週'); + test.done(); + }, + + 'lenient ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing ' + i + ' date check'); + } + test.done(); + }, + + 'lenient ordinal parsing of number' : function (test) { + var i, testMoment; + for (i = 1; i <= 31; ++i) { + testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); + test.equal(testMoment.year(), 2014, + 'lenient ordinal parsing of number ' + i + ' year check'); + test.equal(testMoment.month(), 0, + 'lenient ordinal parsing of number ' + i + ' month check'); + test.equal(testMoment.date(), i, + 'lenient ordinal parsing of number ' + i + ' date check'); + } + test.done(); + }, + + 'strict ordinal parsing' : function (test) { + var i, ordinalStr, testMoment; + for (i = 1; i <= 31; ++i) { + ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); + testMoment = moment(ordinalStr, 'YYYY MM Do', true); + test.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); + } test.done(); } }; -- 2.47.2