mazey
    Preparing search index...

    Function parseLocalDateTime

    • Parse an HTML datetime-local value into a local Date.

      Accepted normalized values use a year with at least four digits followed by -MM-DDTHH:mm, with optional seconds and 1-3 fractional-second digits. Components are validated strictly, so impossible dates and times return null instead of being normalized by Date.

      Usage:

      import { parseLocalDateTime } from "mazey";

      const date = parseLocalDateTime("2026-07-21T14:30:45.123");
      console.log(date?.getFullYear());
      console.log(date?.getHours());
      console.log(date?.getMilliseconds());

      Output:

      2026
      14
      123
      

      Parameters

      • value: string

        A normalized HTML datetime-local value without a timezone.

      Returns Date | null

      A local Date, or null when the value is malformed or represents an impossible local date and time.

      The value is interpreted using the runtime's local timezone. Timezone suffixes, surrounding whitespace, and date-only values are rejected.