Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/locale/ar-sa.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const locale = {
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
meridiem: hour => (hour > 12 ? 'م' : 'ص'),
meridiem: hour => (hour >= 12 ? 'م' : 'ص'),
relativeTime: {
future: 'في %s',
past: 'منذ %s',
Expand Down
17 changes: 17 additions & 0 deletions test/locale/ar-sa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-sa').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-sa').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-sa').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-sa').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-sa').format('A')).toEqual('م')
})

it('Meridiem - 12 PM should show م (PM)', () => {
dayjs.locale(locale)
// Test hour 12 (noon) - should show PM (م)
expect(dayjs('2025-10-28 12:41:00').locale('ar-sa').format('hh:mm a')).toBe('12:41 م')
expect(dayjs('2025-10-28 12:00:00').locale('ar-sa').format('hh:mm a')).toBe('12:00 م')
expect(dayjs('2025-10-28 12:59:59').locale('ar-sa').format('hh:mm a')).toBe('12:59 م')
// Test hour 0 (midnight) - should show AM (ص)
expect(dayjs('2025-10-28 00:41:00').locale('ar-sa').format('hh:mm a')).toBe('12:41 ص')
// Test hours 1-11 should show AM (ص)
expect(dayjs('2025-10-28 01:00:00').locale('ar-sa').format('hh:mm a')).toBe('01:00 ص')
expect(dayjs('2025-10-28 11:00:00').locale('ar-sa').format('hh:mm a')).toBe('11:00 ص')
// Test hours 13-23 should show PM (م)
expect(dayjs('2025-10-28 13:00:00').locale('ar-sa').format('hh:mm a')).toBe('01:00 م')
expect(dayjs('2025-10-28 23:00:00').locale('ar-sa').format('hh:mm a')).toBe('11:00 م')
})