Wrong meridiem in Arabic locale when time is 12 PM
Hi, I noticed a bug when using the Arabic locale (ar-sa) in Day.js
When the time is 12 PM Day.js returns the meridiem as "ص" (AM) instead of "م" (PM)
This only happens at 12 PM other PM hours like 1 PM, 2 PM, etc.. work fine
I also tested it using Vitest and the test fails for the same reason
So it seems like the Arabic locale logic doesn’t handle 12 PM correctly
import { describe, expect, test } from "vitest";
import dayjs from "dayjs";
import "dayjs/locale/ar-sa";
describe("Dayjs Arabic & English", () => {
test("12:41 PM should be م in Arabic", () => {
const result = dayjs("2025-10-28T09:41:10.000000Z").locale("ar-sa").format("hh:mm a");
expect(result).toBe("12:41 م");
});
test("12:41 PM should be pm in English", () => {
const result = dayjs("2025-10-28T09:41:10.000000Z").format("hh:mm a");
expect(result).toBe("12:41 pm");
});
});
AssertionError: expected '12:41 ص' to be '12:41 م' // Object.is equality
Expected: "12:41 م"
Received: "12:41 ص"
@devmashael1-prog what version of dayjs where you able to replicate this ?
@devmashael1-prog was able to replicate this, here's a simple fix https://github.com/iamkun/dayjs/pull/2952 now waiting for feedback from the maintainer
"dayjs": "^1.11.10",
@AnslemHack Great, thanks for the quick fix 🙌 I will test it after merge
I think the same meridiem condition might also need to be updated in the other Arabic locales
@dev-mashael-otb Good point I’ll review the other Arabic locale files and align the meridiem logic for consistency. Appreciate the heads-up!
@dev-mashael-otb I have now extended the fix to other arabic locales @iamkun care to look at this