]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Added test and minor refactor
authorChris Myers <cmyers2015@outlook.com>
Thu, 19 Oct 2017 23:02:54 +0000 (00:02 +0100)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 11 Nov 2017 19:39:22 +0000 (21:39 +0200)
src/lib/locale/locales.js
src/test/moment/locale_update.js

index e45415fcad4c962773133ffb0d2a4d8031d8ec66..7d8fb26e0317f604445f5f69206367918c4a68db 100644 (file)
@@ -133,7 +133,7 @@ export function updateLocale(name, config) {
     if (config != null) {
         var locale, tmpLocale, parentConfig = baseConfig;
         // MERGE
-        tmpLocale = locales[name] || loadLocale(name);
+        tmpLocale = loadLocale(name);
         if (tmpLocale != null) {
             parentConfig = tmpLocale._config;
         }
index ab956b415ff18fc14b0feabf2a1f4da554a7ff2e..3a525e2796dc203d9e233cc1a9800d096d176c44 100644 (file)
@@ -164,3 +164,11 @@ test('months', function (assert) {
     });
     assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child');
 });
+
+test('update existing locale', function (assert) {
+    moment.updateLocale('de', {
+        monthsShort: ['JAN', 'FEB', 'MÄR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEZ']
+    });
+    assert.equal(moment('2017-02-01').format('YYYY MMM MMMM'), '2017 FEB Februar');
+    moment.updateLocale('de', null);
+});