Skip to content

Commit

Permalink
[locale/ar] Fix text direction of D/M/Y formats (redo #2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed May 4, 2015
1 parent e9807f5 commit 1e0b598
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/locale/ar.js
Expand Up @@ -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'
Expand Down Expand Up @@ -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, ',');
},
Expand Down
15 changes: 13 additions & 2 deletions src/test/locale/ar.js
Expand Up @@ -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', 'أحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥']
Expand Down Expand Up @@ -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');
}
}
});

0 comments on commit 1e0b598

Please sign in to comment.