Skip to content

Commit

Permalink
Merge c530f81 into b162aee
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Apr 27, 2020
2 parents b162aee + c530f81 commit d059847
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/locale/locales.js
Expand Up @@ -188,6 +188,12 @@ export function updateLocale(name, config) {
parentConfig = tmpLocale._config;
}
config = mergeConfigs(parentConfig, config);
if (tmpLocale == null) {
// updateLocale is called for creating a new locale
// Set abbr so it will have a name (getters return
// undefined otherwise).
config.abbr = name;
}
locale = new Locale(config);
locale.parentLocale = locales[name];
locales[name] = locale;
Expand Down
8 changes: 8 additions & 0 deletions src/test/moment/locale_update.js
Expand Up @@ -286,6 +286,14 @@ test('update existing locale', function (assert) {
moment.updateLocale('de', null);
});

test('update non-existing locale', function (assert) {
moment.locale('en');
moment.updateLocale('dude', { months: ['Movember'] });
assert.equal(moment.locale(), 'dude');
assert.equal(moment().locale('dude').locale(), 'dude');
moment.defineLocale('dude', null);
});

test('reset locale', function (assert) {
moment.locale('de');
var resultBeforeUpdate = moment('2017-02-01').format('YYYY MMM MMMM');
Expand Down

0 comments on commit d059847

Please sign in to comment.