Parsing and formatting
Typed text is read in the adapter calendar, and dates are formatted in their own calendar. Neither step goes through a JavaScript Date.
Parsing
parse reads user text in the adapter calendar. It does not use Date.parse.
nulland blank text parse tonull. Any other unrecognized value, including a JavaScriptDateor a timestamp, parses to an invalid date.YYYY-MM-DDis year, month, and day in the adapter calendar. On an Umm al-Qura adapter,1445-09-01is 1 Ramadan 1445, and2024-03-11is an invalid date because AH 2024 is outside 1300–1599.D/M/YYYY,D-M-YYYY, andD.M.YYYYare day, month, and year. When the first number is greater than 31, the same separators are read as year, month, and day, so1447/10/15is 15 Shawwal 1447.D Month YYYYaccepts the fixed English and Arabic Umm al-Qura month names on an Umm al-Qura adapter, and the active locale's month names on a Gregorian adapter.- Arabic-Indic digits (
٠–٩) and Persian digits (۰–۹) are accepted. - Text outside AH 1300–1599 parses to an invalid date.
Serialization
deserialize accepts null, '', a CalendarDate, or a zero-padded YYYY-MM-DD in the adapter calendar. toIso8601 returns that same YYYY-MM-DD with ASCII digits. It is the adapter calendar's date, not a Gregorian conversion and not Date#toISOString.
Formatting
HIJRI_DATE_FORMATS follows Material's format slots. A numeric month renders as day/month/year. A long, short, or narrow month renders as day month, year, with the Arabic comma ، for Arabic locales. Digits follow the locale.
formatCalendarDate(date, locale, options) applies the same rules outside the adapter:
import { createCalendarDate, formatCalendarDate } from 'ngx-mat-hijri-adapter';
formatCalendarDate(createCalendarDate('islamic-umalqura', 1445, 9, 1), 'en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
}); // '1 Ramadan, 1445' Umm al-Qura month names are fixed: Arabic when the locale starts with ar, English otherwise. Gregorian month names and all weekday names come from Intl. Formatting an invalid date throws.