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).
53 lines (49 loc) • 2.41 kB
TypeScript
import { N as NumeralSystem } from './types-CK7PVYeU.js';
/** A date on the Hijri (Islamic) calendar. Months are 1-based (1 = Muharram). */
interface HijriDate {
year: number;
month: number;
day: number;
}
/** Arabic names of the twelve Hijri months (index 0 = Muharram). */
declare const HIJRI_MONTHS_AR: readonly string[];
/** Transliterated English names of the twelve Hijri months. */
declare const HIJRI_MONTHS_EN: readonly string[];
/** Era marker: "هـ" in Arabic, "AH" otherwise. */
declare const HIJRI_ERA_AR = "\u0647\u0640";
declare const HIJRI_ERA_EN = "AH";
/** Arabic names of the twelve Gregorian months (index 0 = January). */
declare const GREGORIAN_MONTHS_AR: readonly string[];
/** English names of the twelve Gregorian months (index 0 = January). */
declare const GREGORIAN_MONTHS_EN: readonly string[];
/**
* Arabic weekday names (index 0 = Sunday, matching `Date.prototype.getDay()`).
*/
declare const ARABIC_WEEKDAYS_AR: readonly string[];
/** English weekday names (index 0 = Sunday). */
declare const ARABIC_WEEKDAYS_EN: readonly string[];
interface FormatHijriOptions {
/** Language for month names and era. Default `"ar"`. */
locale?: string;
/** Digit shaping. Default `"latn"` — Eastern Arabic digits are opt-in. */
numerals?: NumeralSystem;
/** Month rendering. Default `"long"` (named month). */
month?: "long" | "numeric" | "2-digit";
/** Day rendering. Default `"numeric"`. */
day?: "numeric" | "2-digit";
/** Append the era marker (AH / هـ). Default `true`. */
era?: boolean;
/** Field order. Default `"dmy"`. */
order?: "dmy" | "ymd";
/** Field separator. Default `" "` for named months, `"/"` otherwise. */
separator?: string;
}
/**
* Format a {@link HijriDate} deterministically — same output on Node, browsers
* and React Native, unlike `Intl`'s Hijri formatting which varies by engine.
*
* @example formatHijriDate({ year: 1447, month: 1, day: 1 })
* // "1 Muharram 1447 AH" (locale "ar" gives "1 محرّم 1447 هـ")
*/
declare function formatHijriDate(hijri: HijriDate, options?: FormatHijriOptions): string;
export { ARABIC_WEEKDAYS_AR as A, type FormatHijriOptions as F, GREGORIAN_MONTHS_AR as G, HIJRI_ERA_AR as H, ARABIC_WEEKDAYS_EN as a, GREGORIAN_MONTHS_EN as b, HIJRI_ERA_EN as c, HIJRI_MONTHS_AR as d, HIJRI_MONTHS_EN as e, type HijriDate as f, formatHijriDate as g };