Utilities
Parsing
Turn date strings into Date objects, with strict mode and structured parse results when you need validation details.
Start Here
Use parsing when the user gives you a date string and you need a JavaScript Date back.
Quick Rule
If the input is text and the next step is date math or formatting, parse it first.
Use parseDate() when you only need a Date | null.
Use parseDateDetailed() when you need validation reasons like strict_mismatch or invalid_bangla_calendar_date.
Supported Inputs
| Input type | Example |
|---|---|
| ISO date | 2026-03-31 |
| ISO timestamp | 2026-03-31T15:30:00Z |
| Gregorian text | 31 March 2026 |
| Bangla calendar text | 17 Chaitra 1432 |
| Legacy Bangla month names | Boishakh, Poush, Falgun, Asharh |
Example
import { parseDate, parseDateDetailed } from "@coreify/tarikh";
parseDate("৩১ মার্চ ২০২৬");
// -> Date object (March 31, 2026)
parseDate("17 Chaitra 1432", { calendar: "bangla" });
// -> Date object (March 31, 2026)
parseDate("2026-03-31T15:30:00Z");
// -> Date object (March 31, 2026, 3:30 PM UTC)
parseDate("31 Mar 26", { strict: true });
// -> null
parseDateDetailed("31 Mar 26", { strict: true });
// -> { success: false, reason: "strict_mismatch", ... }What It Returns
| Input | Result |
|---|---|
| Valid date string | A JavaScript Date |
| Bangla calendar string | A normalized Date when calendar: "bangla" is provided |
| Invalid input | null from parseDate() |
| Detailed validation | A success or failure object from parseDateDetailed() |
Good Fit
Use this when your app accepts user input, imports date text, or needs to normalize dates before formatting.