]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Introduce month.isFormat for format/standalone discovery
authorIskren Chernev <iskren.chernev@gmail.com>
Sun, 12 Jun 2016 08:18:35 +0000 (01:18 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 15 Jun 2016 09:18:29 +0000 (02:18 -0700)
Fixes #3195

src/lib/units/month.js
src/locale/lt.js
src/test/locale/lt.js

index 5de0077e8831d038bbc191625b0a8e397c5d5257..651e80df4ed9c7d2f8b55ed7cd7078755bfb0dc8 100644 (file)
@@ -70,7 +70,7 @@ var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/;
 export var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
 export function localeMonths (m, format) {
     return isArray(this._months) ? this._months[m.month()] :
-        this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
+        this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
 }
 
 export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
index b2900db24cabc99840692310a08d901cc5aea2d1..ce1ab2c5485744a549bd56c524a23ae88491181d 100644 (file)
@@ -49,7 +49,8 @@ function translate(number, withoutSuffix, key, isFuture) {
 export default moment.defineLocale('lt', {
     months : {
         format: 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_'),
-        standalone: 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_')
+        standalone: 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
+        isFormat: /MMMM?(\[[^\[\]]*\]|\s+)+D[oD]?/
     },
     monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
     weekdays : {
index 45bf2e550797fc5fec8b064bc15505666833418d..7c8e2f608344f0b2a010041283bbbdb36b8d5261 100644 (file)
@@ -22,7 +22,7 @@ test('parse', function (assert) {
 
 test('format', function (assert) {
     var a = [
-            ['dddd, Do MMMM YYYY, h:mm:ss a',      'sekmadienis, 14-oji vasario 2010, 3:25:50 pm'],
+            ['dddd, Do MMMM YYYY, h:mm:ss a',      'sekmadienis, 14-oji vasaris 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Sek, 3PM'],
             ['M Mo MM MMMM MMM',                   '2 2-oji 02 vasaris vas'],
             ['YYYY YY',                            '2010 10'],
@@ -38,13 +38,13 @@ test('format', function (assert) {
             ['DDDo [metų diena]',                  '45-oji metų diena'],
             ['LTS',                                '15:25:50'],
             ['L',                                  '2010-02-14'],
-            ['LL',                                 '2010 m. vasaris 14 d.'],
-            ['LLL',                                '2010 m. vasaris 14 d., 15:25 val.'],
-            ['LLLL',                               '2010 m. vasaris 14 d., sekmadienis, 15:25 val.'],
+            ['LL',                                 '2010 m. vasario 14 d.'],
+            ['LLL',                                '2010 m. vasario 14 d., 15:25 val.'],
+            ['LLLL',                               '2010 m. vasario 14 d., sekmadienis, 15:25 val.'],
             ['l',                                  '2010-02-14'],
-            ['ll',                                 '2010 m. vasaris 14 d.'],
-            ['lll',                                '2010 m. vasaris 14 d., 15:25 val.'],
-            ['llll',                               '2010 m. vasaris 14 d., Sek, 15:25 val.']
+            ['ll',                                 '2010 m. vasario 14 d.'],
+            ['lll',                                '2010 m. vasario 14 d., 15:25 val.'],
+            ['llll',                               '2010 m. vasario 14 d., Sek, 15:25 val.']
         ],
         b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
@@ -224,3 +224,6 @@ test('weeks year starting sunday formatted', function (assert) {
     assert.equal(moment([2012, 0, 15]).format('w ww wo'),  '2 02 2-oji', 'Jan 15 2012 should be week 2');
 });
 
+test('month cases', function (assert) {
+    assert.equal(moment([2015, 4, 1]).format('LL'), '2015 m. gegužės 1 d.', 'uses format instead of standalone form');
+});