parsePartial
Parses an ISO date that may only be known to the year or the month: YYYY, YYYY-MM or
YYYY-MM-DD. A partial date is anchored in the middle of its period, so it sorts and
charts sensibly next to full dates:
YYYY→ July 1st of that yearYYYY-MM→ the 15th of that monthYYYY-MM-DD→ that day
All dates are at 00:00:00.000 UTC. Returns null for anything else, including a month or day
that does not exist (2025-13, 2025-02-30).
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input | string | A `YYYY`, `YYYY-MM` or `YYYY-MM-DD` string |
Returns
Section titled “Returns”PartialDate | null — The anchored date with its precision, or null
Examples
Section titled “Examples”Year and month only
Section titled “Year and month only”A partial date is anchored in the middle of its period so it sorts next to full dates.
Invalid input
Section titled “Invalid input”A month or day that does not exist gives null.
Related Types
Section titled “Related Types”PartialDate
Section titled “PartialDate”A partial ISO date resolved to a concrete Date, with the precision it had.
PartialDatePrecision
Section titled “PartialDatePrecision”Precision of a partial ISO date: which parts the input actually gave.
