Skip to content

Commit 361be5c

Browse files
authored
fix(locale): add meridiem in ar locale (iamkun#2418)
1 parent a9d7d03 commit 361be5c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/locale/ar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import dayjs from 'dayjs'
33

44
const months = 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_')
5+
56
const symbolMap = {
67
1: '١',
78
2: '٢',
@@ -36,6 +37,7 @@ const locale = {
3637
months,
3738
monthsShort: months,
3839
weekStart: 6,
40+
meridiem: hour => (hour > 12 ? 'م' : 'ص'),
3941
relativeTime: {
4042
future: 'بعد %s',
4143
past: 'منذ %s',

test/locale/ar.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ it('RelativeTime: Time from X gets formatted', () => {
5050
.toBe(t[2])
5151
})
5252
})
53+
54+
it('Format meridiem with locale function', () => {
55+
for (let i = 0; i <= 23; i += 1) {
56+
const hour = dayjs()
57+
.startOf('day')
58+
.add(i, 'hour')
59+
const meridiem = i > 12 ? 'م' : 'ص'
60+
expect(hour.locale('ar').format('A')).toBe(`${meridiem}`)
61+
}
62+
})

0 commit comments

Comments
 (0)