Formatting
Bangla and Hijri Calendar
Get Bangla or Hijri calendar values as data objects when you need the parts, not just the string.
Start Here
Use these helpers when you want the calendar values themselves, not just a formatted string.
Quick Rule
If your UI needs day, month, and year as data, start here.
If your UI only needs a display string, go back to Formatting.
What You Get
| Helper | Returns |
|---|---|
toBanglaCalendar() | Bangla calendar parts |
toHijriCalendar() | Hijri calendar parts |
Both helpers are locale-aware in TypeScript:
- literal
"en-BD"returns numeric English-shaped data - literal
"bn-BD"returns localized string-shaped data - dynamic
Localevariables return a safe union result type
Bangla Calendar
import { toBanglaCalendar } from "@coreify/tarikh";
toBanglaCalendar("2026-03-31");
// -> { day: 17, month: "Chaitra", monthIndex: 12, year: 1432 }
toBanglaCalendar("2026-03-31", { locale: "bn-BD" });
// -> { day: "১৭", month: "চৈত্র", monthIndex: 12, year: "১৪৩২" }
const locale: "en-BD" | "bn-BD" = Math.random() > 0.5 ? "en-BD" : "bn-BD";
const structuredBangla = toBanglaCalendar("2026-03-31", { locale });
// -> BanglaCalendarResult<"en-BD" | "bn-BD">Hijri Calendar
import { HIJRI_TIME_ZONES, toHijriCalendar } from "@coreify/tarikh";
const [defaultHijriZone, utcHijriZone] = HIJRI_TIME_ZONES;
toHijriCalendar("2026-03-31");
// -> { day: 11, month: "Shawwal", monthIndex: 10, year: 1447 }
toHijriCalendar("2026-03-31", { locale: "bn-BD" });
// -> { day: "১১", month: "শাওয়াল", monthIndex: 10, year: "১৪৪৭" }
toHijriCalendar("2026-03-31", { timeZone: "UTC" });
// -> { day: 11, month: "Shawwal", monthIndex: 10, year: 1447 }
toHijriCalendar("2026-03-31", { hijriSystem: "islamic-civil" });
// -> Civil Hijri output backed by Intl
const structuredHijri = toHijriCalendar("2026-03-31", { locale });
// -> HijriCalendarResult<"en-BD" | "bn-BD">Good Fit
- Use
toBanglaCalendar()when you need the Bangla calendar directly - Use
toHijriCalendar()when you need the Hijri date object for logic or display - Use
format()when you want the finished string right away