Documentation / @jalali-js/i18n
@jalali-js/i18n
Locale data and display formatting for jalali-js.
sh
npm install @jalali-js/i18nts
import { format, parseTemplate, en, fa, ps } from '@jalali-js/i18n';
const date = {
precision: 'date' as const,
system: 'jalali' as const,
year: 1403,
month: 5,
day: 15,
};
format(date, en); // '15 Mordad 1403'
format(date, fa); // '۱۵ مرداد ۱۴۰۳'
format(date, ps); // '۱۵ زمری ۱۴۰۳' (Pashto, with Afghanistan's month names)
format(date, en, { template: 'YYYY/MM/DD' }); // '1403/05/15'
parseTemplate('1403/05/15', 'YYYY/MM/DD', en); // the date above, or null on a mismatchThree locales ship today, en, fa, and ps, each covering both calendar systems' month names (English transliterations of the Jalali months, Persian transliterations of the Gregorian ones, Afghanistan's zodiac-based month names in Pashto), weekday names, digit style, and text direction. @jalali-js/react, @jalali-js/vue, and @jalali-js/web already depend on this package and wire it up through a locale prop or attribute; reach for it directly only when formatting a date outside a component.
Guide and API reference · Examples · Playground
MIT licensed.