Documentation / @jalali-js/nlp
@jalali-js/nlp
Natural language date parsing for jalali-js in English, Farsi, and Pashto.
Start here: Live demo · Documentation
npm ecosystem: jalali-js · @jalali-js/i18n · @jalali-js/nlp · @jalali-js/holidays · @jalali-js/react · @jalali-js/vue · @jalali-js/web · @jalali-js/ui-react · @jalali-js/ui-vue · @jalali-js/ui-web
Contents
Install
sh
npm install @jalali-js/nlpCompatibility
| Item | Support |
|---|---|
| Locales | en, fa, ps |
| Dependencies | jalali-js, @jalali-js/i18n |
| Node | 22 and 24 (CI matrix) |
Quick start
ts
import { parse } from '@jalali-js/nlp';
parse('tomorrow', 'en'); // CalendarDate | null
parse('فردا', 'fa');
parse('نن', 'ps');
parse('next Farvardin', 'en');
parse('۱۵ مرداد ۱۴۰۳', 'fa');Returns a CalendarDate, or null when the input is unclear.
API
| Export | Role |
|---|---|
parse | Parse a phrase into a CalendarDate |
getWordList | Locale word list used by the parser |
Relative words (today, tomorrow, next week), month names, and numeric dates are covered per locale. Farsi uses Persian script. English accepts transliterated Jalali month names (Mehr, Aban).
Options
ts
parse(input, locale, { system?: 'jalali' | 'gregorian' });| Option | Values | Default | Notes |
|---|---|---|---|
locale | 'en' | 'fa' | 'ps' | required | Word list and digits |
system | 'jalali' | 'gregorian' | 'jalali' | Calendar for result |
Guide: NLP.
Theming
This package has no UI.
Links
License
MIT