parseLocalDate
Calendar
stable
Parse a `"YYYY-MM-DD"` string into a local-time `Date` by splitting on `-` and passing individual components to `new Date()`. This avoids the UTC offset that the single-argument `new Date(string)` constructor introduces.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- valuerequiredstring
- A `"YYYY-MM-DD"` date string. The components are split and passed as separate numeric arguments to `new Date()` to force local time zone.
API
Return value
The value returned by this util.
- A `Date` set to midnight in the user's local time zone. Avoids the off-by-one-day bug that `new Date("YYYY-MM-DD")` triggers when the timezone offset is negative.
Usage
Examples
Ready-to-paste usage snippets.
Parse a date without timezone shift