]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Added a way to uninstall a language definition 911/head
authorIskren Chernev <iskren.chernev@gmail.com>
Sun, 14 Jul 2013 05:01:00 +0000 (22:01 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 14 Jul 2013 05:01:00 +0000 (22:01 -0700)
moment.lang(key, null) now uninstalls a language. That's mostly useful to
remove auxiliary languages added during test runs.

moment.js
test/moment/create.js
test/moment/format.js
test/moment/weekday.js

index c1673c1272832c9176923f2d58dce8c3bb7c4535..a532663cba5b20ab529d2871a14ea614705165d3 100644 (file)
--- a/moment.js
+++ b/moment.js
         return languages[key];
     }
 
+    // Remove a language from the `languages` cache. Mostly useful in tests.
+    function unloadLang(key) {
+        delete languages[key];
+    }
+
     // Determines which language definition to use and returns it.
     //
     // With no parameters, it will return the global language.  If you
         }
         if (values) {
             loadLang(key, values);
+        } else if (values === null) {
+            unloadLang(key);
+            key = 'en';
         } else if (!languages[key]) {
             getLangDefinition(key);
         }
index 2290fb41df456e77729e91bde06de9c066634c0b..0f3f06bc84f70a1f650fa3a4c0565b095230bf26 100644 (file)
@@ -458,6 +458,7 @@ exports.create = {
 
         test.equal(moment('2012 july', 'YYYY MMM', 'en').month(), 6, "should be able to parse in a specific language");
 
+        moment.lang('parselang', null);
         test.done();
     }
 };
index 1534c064543b681c0d3aec8997980f1e842f6384..2907cec6d9833ac47df842ad168ff363889292a7 100644 (file)
@@ -303,6 +303,7 @@ exports.format = {
 
         moment.lang('postformat', {postformat: function(s) { s.replace(/./g, 'X') }});
         test.equal(moment.utc([2000, 0, 1]).toJSON(), "2000-01-01T00:00:00.000Z", "toJSON doesn't postformat");
+        moment.lang('postformat', null);
         test.done();
     }
 };
index ef1571e341b9bc04389f97fc3b608748b8d1df18..60016439fc82da0197dcd9d0c5be123fc7f0a163 100644 (file)
@@ -110,6 +110,7 @@ exports.week_year = {
         test.equal(moment([1970, 0,  4]).weekday(), 4, "Jan  4 1970 is Sunday    -- 4th day");
         test.equal(moment([2001, 4, 14]).weekday(), 5, "May 14 2001 is Monday    -- 5th day");
         test.equal(moment([2000, 0,  4]).weekday(), 6, "Jan  4 2000 is Tuesday   -- 6th day");
+        moment.lang('dow:3,doy:6', null);
         test.done();
     },