]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix localeData months on Greek (#3868)
authorAlessandro Di Felice <alessandro.difelice@gmail.com>
Thu, 3 Aug 2017 01:34:35 +0000 (20:34 -0500)
committerMaggie Pint <maggiepint@gmail.com>
Thu, 3 Aug 2017 01:34:35 +0000 (18:34 -0700)
src/locale/el.js
src/test/locale/el.js

index facd7f6a2ac83e5dcd81cc94ff569ca4466fe4ab..6648da0f8c559da6fcdc194712f2899a6e6707f5 100644 (file)
@@ -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()];
index 738490dc37b560b0e52689182749261681304e69..0c55b2e780130a37ca2c6180216f8060e01d16a7 100644 (file)
@@ -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');
+});