From: Alessandro Di Felice Date: Thu, 3 Aug 2017 01:34:35 +0000 (-0500) Subject: Fix localeData months on Greek (#3868) X-Git-Tag: 2.19.0~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=555c00d010f22e059028cbf6eddd8a24c9182969;p=thirdparty%2Fmoment.git Fix localeData months on Greek (#3868) --- diff --git a/src/locale/el.js b/src/locale/el.js index facd7f6a2..6648da0f8 100644 --- a/src/locale/el.js +++ b/src/locale/el.js @@ -11,7 +11,7 @@ export default moment.defineLocale('el', { months : function (momentToFormat, format) { if (!momentToFormat) { return this._monthsNominativeEl; - } else if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM' + } else if (typeof format === 'string' && /D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM' return this._monthsGenitiveEl[momentToFormat.month()]; } else { return this._monthsNominativeEl[momentToFormat.month()]; diff --git a/src/test/locale/el.js b/src/test/locale/el.js index 738490dc3..0c55b2e78 100644 --- a/src/test/locale/el.js +++ b/src/test/locale/el.js @@ -258,3 +258,8 @@ test('weeks year starting sunday format', function (assert) { assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2'); }); +test('localeData months calls', function (assert) { + var jan = moment('2012-01-01'); + assert.equal(moment.localeData().months(jan), 'Ιανουάριος', 'should return the nominative month name'); + assert.equal(moment.localeData().months(jan, 'D MMMM'), 'Ιανουαρίου', 'should return the genitive month name'); +});