]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Parse Dutch abbreviated month name without dot
authorJacob Middag <jacob@gaddim.nl>
Wed, 22 Jun 2016 13:16:03 +0000 (15:16 +0200)
committerIskren Chernev <iskren.chernev@gmail.com>
Thu, 1 Sep 2016 09:38:58 +0000 (02:38 -0700)
src/locale/nl.js
src/test/locale/nl.js

index ddc5a0d21cf0e7a9a6fb527a3e1bcdb9ec238bf1..0988cfe6a9ec9d749fe270376f0ee27b6e6bed8e 100644 (file)
@@ -1,12 +1,16 @@
 //! moment.js locale configuration
 //! locale : Dutch [nl]
-//! author : Joris Röling : https://github.com/jjupiter
+//! author : Joris Röling : https://github.com/jorisroling
+//! author : Jacob Middag : https://github.com/middagj
 
 import moment from '../moment';
 
 var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'),
     monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
 
+var monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
+var monthsRegex = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
+
 export default moment.defineLocale('nl', {
     months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
     monthsShort : function (m, format) {
@@ -16,7 +20,16 @@ export default moment.defineLocale('nl', {
             return monthsShortWithDots[m.month()];
         }
     },
-    monthsParseExact : true,
+
+    monthsRegex: monthsRegex,
+    monthsShortRegex: monthsRegex,
+    monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
+    monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
+
+    monthsParse : monthsParse,
+    longMonthsParse : monthsParse,
+    shortMonthsParse : monthsParse,
+
     weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
     weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
     weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
index d0f7533d61381366ec08f44ed8dcef075b07499b..21fca332fe6761899257091ba2ea619b72fedba4 100644 (file)
@@ -201,7 +201,9 @@ test('calendar all else', function (assert) {
 
 test('month abbreviation', function (assert) {
     assert.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
+    assert.equal(moment([2012, 5, 23]).unix(), moment('23-jun-2012', 'D-MMM-YYYY').unix(), 'parse month abbreviation surrounded by dashes without dot');
     assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
+    assert.equal(moment([2012, 5, 23]).unix(), moment('23 jun. 2012', 'D MMM YYYY').unix(), 'parse month abbreviation not surrounded by dashes with dot');
 });
 
 test('weeks year starting sunday formatted', function (assert) {