diff --git a/src/locale/ar-sa.js b/src/locale/ar-sa.js index f543bac22..c65d2f9fb 100644 --- a/src/locale/ar-sa.js +++ b/src/locale/ar-sa.js @@ -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', diff --git a/test/locale/ar-sa.test.js b/test/locale/ar-sa.test.js index 1936f5086..808846e22 100644 --- a/test/locale/ar-sa.test.js +++ b/test/locale/ar-sa.test.js @@ -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 م') +})