UNPKG

arabicfmt

Version:

Arabic-first formatting for numbers, currency, dates and bidirectional text across all 22 Arab League countries — with correct handling of the 2025–2026 Unicode currency-symbol transition (Saudi Riyal U+20C1, UAE Dirham U+20C3, Omani Rial U+20C4).

30 lines (26 loc) 993 B
import { dateToJDN, jdnToDate, formatHijriDate } from './chunk-WD4UJ23C.js'; // src/date/hijri.ts var ISLAMIC_EPOCH = 1948440; function tabularToJDN(year, month, day) { return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + ISLAMIC_EPOCH - 1; } function tabularFromJDN(jdn) { let year = Math.floor((30 * (jdn - ISLAMIC_EPOCH) + 10646) / 10631); while (tabularToJDN(year, 1, 1) > jdn) year--; while (tabularToJDN(year + 1, 1, 1) <= jdn) year++; let month = 1; while (month < 12 && tabularToJDN(year, month + 1, 1) <= jdn) month++; const day = jdn - tabularToJDN(year, month, 1) + 1; return { year, month, day }; } function toHijri(date) { return tabularFromJDN(dateToJDN(date)); } function fromHijri(year, month, day) { return jdnToDate(tabularToJDN(year, month, day)); } // src/date/index.ts function formatHijri(date, options) { return formatHijriDate(toHijri(date), options); } export { formatHijri, fromHijri, toHijri };