]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Remove RTL scraping from preparse
authorKunal Marwaha <marwahaha@berkeley.edu>
Wed, 29 Mar 2017 08:21:11 +0000 (04:21 -0400)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 6 Aug 2017 23:35:35 +0000 (02:35 +0300)
src/locale/ar-ly.js
src/locale/ar.js
src/test/locale/ar-ly.js
src/test/locale/ar.js

index 2dcba3f684af2a1d61a165b2710f43675423c2eb..fb3a3e7736e6279b6d63843c32870c79434169b5 100644 (file)
@@ -98,7 +98,7 @@ export default moment.defineLocale('ar-ly', {
         yy : pluralize('y')
     },
     preparse: function (string) {
-        return string.replace(/\u200f/g, '').replace(/،/g, ',');
+        return string.replace(/،/g, ',');
     },
     postformat: function (string) {
         return string.replace(/\d/g, function (match) {
index 619843ae560d0f6bd54bef9087b00cbd23f25cab..4d4a8a473de1442be11a91dddaba2096fed2287f 100644 (file)
@@ -111,7 +111,7 @@ export default moment.defineLocale('ar', {
         yy : pluralize('y')
     },
     preparse: function (string) {
-        return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
+        return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
             return numberMap[match];
         }).replace(/،/g, ',');
     },
@@ -125,4 +125,3 @@ export default moment.defineLocale('ar', {
         doy : 12  // The week that contains Jan 1st is the first week of the year.
     }
 });
-
index a3d1ae717008d63d7ee8182310794fa850454fbb..0b7679123830e8c15e31bb212a9f1d8a54575618 100644 (file)
@@ -240,3 +240,11 @@ test('no leading zeros in long date formats', function (assert) {
         }
     }
 });
+
+// locale-specific
+test('ar-ly strict mode parsing works', function (assert) {
+    const m = moment().locale('ar-ly');
+    const formattedDate = m.format('l');
+    assert.equal(moment.utc(formattedDate, 'l', 'ar-ly', false).isValid(), true, 'Non-strict parsing works');
+    assert.equal(moment.utc(formattedDate, 'l', 'ar-ly', true).isValid(), true,'Strict parsing must work');
+});
index dc847ab653e4ced063c10d8e9a920914c4fe2d85..b87b2aa1f7fd8ab62a9a6c1798a04ce991feb367 100644 (file)
@@ -240,3 +240,11 @@ test('no leading zeros in long date formats', function (assert) {
         }
     }
 });
+
+// locale-specific
+test('ar strict mode parsing works', function (assert) {
+    const m = moment().locale('ar');
+    const formattedDate = m.format('l');
+    assert.equal(moment.utc(formattedDate, 'l', 'ar', false).isValid(), true, 'Non-strict parsing works');
+    assert.equal(moment.utc(formattedDate, 'l', 'ar', true).isValid(), true,'Strict parsing must work');
+});