From: Iskren Chernev Date: Mon, 4 May 2015 04:28:25 +0000 (-0700) Subject: [locale/ar] Fix text direction of D/M/Y formats (redo #2268) X-Git-Tag: 2.10.3~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e0b5986b270de62c72d2b6a3cc6d1fd948ffe0c;p=thirdparty%2Fmoment.git [locale/ar] Fix text direction of D/M/Y formats (redo #2268) --- diff --git a/src/locale/ar.js b/src/locale/ar.js index d3a5bfcc5..689bc8f6a 100644 --- a/src/locale/ar.js +++ b/src/locale/ar.js @@ -70,7 +70,7 @@ export default moment.defineLocale('ar', { longDateFormat : { LT : 'HH:mm', LTS : 'HH:mm:ss', - L : 'DD/MM/YYYY', + L : 'D/\u200FM/\u200FYYYY', LL : 'D MMMM YYYY', LLL : 'D MMMM YYYY LT', LLLL : 'dddd D MMMM YYYY LT' @@ -110,7 +110,7 @@ export default moment.defineLocale('ar', { yy : pluralize('y') }, preparse: function (string) { - return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { + return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { return numberMap[match]; }).replace(/،/g, ','); }, diff --git a/src/test/locale/ar.js b/src/test/locale/ar.js index 067a17643..7565e1734 100644 --- a/src/test/locale/ar.js +++ b/src/test/locale/ar.js @@ -52,11 +52,11 @@ test('format', function (assert) { ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'], ['LT', '١٥:٢٥'], ['LTS', '١٥:٢٥:٥٠'], - ['L', '١٤/٠٢/٢٠١٠'], + ['L', '١٤/\u200f٢/\u200f٢٠١٠'], ['LL', '١٤ شباط فبراير ٢٠١٠'], ['LLL', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'], ['LLLL', 'الأحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'], - ['l', '١٤/٢/٢٠١٠'], + ['l', '١٤/\u200f٢/\u200f٢٠١٠'], ['ll', '١٤ شباط فبراير ٢٠١٠'], ['lll', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'], ['llll', 'أحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'] @@ -322,3 +322,14 @@ test('strict ordinal parsing', function (assert) { assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); } }); + +test('no leading zeros in long date formats', function (assert) { + var i, j, longDateStr, shortDateStr; + for (i = 1; i <= 9; ++i) { + for (j = 1; j <= 9; ++j) { + longDateStr = moment([2014, i, j]).format('L'); + shortDateStr = moment([2014, i, j]).format('l'); + assert.equal(longDateStr, shortDateStr, 'should not have leading zeros in month or day'); + } + } +});