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-dz.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
2 changes: 1 addition & 1 deletion src/locale/ar-iq.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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
2 changes: 1 addition & 1 deletion src/locale/ar-kw.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
2 changes: 1 addition & 1 deletion src/locale/ar-ly.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const locale = {
monthsShort: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
ordinal: n => n,
meridiem: hour => (hour > 12 ? 'م' : 'ص'),
meridiem: hour => (hour >= 12 ? 'م' : 'ص'),
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/ar-ma.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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
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
2 changes: 1 addition & 1 deletion src/locale/ar-tn.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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
2 changes: 1 addition & 1 deletion src/locale/ar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const locale = {
months,
monthsShort: months,
weekStart: 6,
meridiem: hour => (hour > 12 ? 'م' : 'ص'),
meridiem: hour => (hour >= 12 ? 'م' : 'ص'),
relativeTime: {
future: 'بعد %s',
past: 'منذ %s',
Expand Down
1 change: 1 addition & 0 deletions test/locale/ar-dz.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-dz').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-dz').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-dz').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-dz').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-dz').format('A')).toEqual('م')
})
1 change: 1 addition & 0 deletions test/locale/ar-iq.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-iq').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-iq').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-iq').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-iq').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-iq').format('A')).toEqual('م')
})
1 change: 1 addition & 0 deletions test/locale/ar-kw.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-kw').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-kw').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-kw').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-kw').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-kw').format('A')).toEqual('م')
})
1 change: 1 addition & 0 deletions test/locale/ar-ly.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-ly').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-ly').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-ly').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-ly').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-ly').format('A')).toEqual('م')
})
1 change: 1 addition & 0 deletions test/locale/ar-ma.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-ma').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-ma').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-ma').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-ma').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-ma').format('A')).toEqual('م')
})
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 م')
})
1 change: 1 addition & 0 deletions test/locale/ar-tn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Meridiem', () => {
dayjs.locale(locale)
expect(dayjs('2020-01-01 03:00:00').locale('ar-tn').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 11:00:00').locale('ar-tn').format('A')).toEqual('ص')
expect(dayjs('2020-01-01 12:00:00').locale('ar-tn').format('A')).toEqual('م')
expect(dayjs('2020-01-01 16:00:00').locale('ar-tn').format('A')).toEqual('م')
expect(dayjs('2020-01-01 20:00:00').locale('ar-tn').format('A')).toEqual('م')
})
13 changes: 4 additions & 9 deletions test/locale/ar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,18 @@ it('Preparse with locale function', () => {
})

it('RelativeTime: Time from X gets formatted', () => {
const T = [
[44.4, 'second', 'منذ ثانية واحدة']
]
const T = [[44.4, 'second', 'منذ ثانية واحدة']]

T.forEach((t) => {
dayjs.locale('ar')
expect(dayjs().from(dayjs().add(t[0], t[1])))
.toBe(t[2])
expect(dayjs().from(dayjs().add(t[0], t[1]))).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 ? 'م' : 'ص'
const hour = dayjs().startOf('day').add(i, 'hour')
const meridiem = i >= 12 ? 'م' : 'ص'
expect(hour.locale('ar').format('A')).toBe(`${meridiem}`)
}
})