From 361be5c7c628614ee833d710acbe154a598b904d Mon Sep 17 00:00:00 2001 From: Aland Abdullah <32212842+alandio@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:36:25 +0300 Subject: [PATCH] fix(locale): add meridiem in `ar` locale (#2418) --- src/locale/ar.js | 2 ++ test/locale/ar.test.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/locale/ar.js b/src/locale/ar.js index a7025c442..f418379c8 100644 --- a/src/locale/ar.js +++ b/src/locale/ar.js @@ -2,6 +2,7 @@ import dayjs from 'dayjs' const months = 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_') + const symbolMap = { 1: '١', 2: '٢', @@ -36,6 +37,7 @@ const locale = { months, monthsShort: months, weekStart: 6, + meridiem: hour => (hour > 12 ? 'م' : 'ص'), relativeTime: { future: 'بعد %s', past: 'منذ %s', diff --git a/test/locale/ar.test.js b/test/locale/ar.test.js index 3f9f60f0c..2b5a57d29 100644 --- a/test/locale/ar.test.js +++ b/test/locale/ar.test.js @@ -50,3 +50,13 @@ it('RelativeTime: Time from X gets formatted', () => { .toBe(t[2]) }) }) + +it('Format meridiem with locale function', () => { + for (let i = 0; i <= 23; i += 1) { + const hour = dayjs() + .startOf('day') + .add(i, 'hour') + const meridiem = i > 12 ? 'م' : 'ص' + expect(hour.locale('ar').format('A')).toBe(`${meridiem}`) + } +})