Module

Temporal.Format.Html

Package
purescript-temporal
Repository
philippedev101/purescript-temporal

Formatting and parsing for HTML5 date/time input elements.

HTML5 <input> elements use specific string formats that differ from full ISO 8601. This module handles the conversion.

| Input type | Format | Example | |--------------------|-------------------|----------------------| | date | YYYY-MM-DD | "2024-03-15" | | time | HH:MM | "14:30" | | datetime-local | YYYY-MM-DDTHH:MM| "2024-03-15T14:30" | | month | YYYY-MM | "2024-03" |

#toHtmlDate Source

toHtmlDate :: PlainDate -> String

Format a PlainDate for <input type="date">.

Produces "YYYY-MM-DD" (e.g. "2024-03-15").

#fromHtmlDate Source

fromHtmlDate :: String -> Maybe PlainDate

Parse a value from <input type="date">.

Accepts "YYYY-MM-DD" format.

#toHtmlTime Source

toHtmlTime :: PlainTime -> String

Format a PlainTime for <input type="time">.

Produces "HH:MM" (e.g. "14:30"), truncating seconds and sub-seconds.

#fromHtmlTime Source

fromHtmlTime :: String -> Maybe PlainTime

Parse a value from <input type="time">.

Accepts "HH:MM" and "HH:MM:SS" formats (browsers may include seconds when the step attribute is set).

#toHtmlDateTime Source

toHtmlDateTime :: PlainDateTime -> String

Format a PlainDateTime for <input type="datetime-local">.

Produces "YYYY-MM-DDTHH:MM" (e.g. "2024-03-15T14:30"), truncating seconds and sub-seconds.

#fromHtmlDateTime Source

fromHtmlDateTime :: String -> Maybe PlainDateTime

Parse a value from <input type="datetime-local">.

Accepts "YYYY-MM-DDTHH:MM" and "YYYY-MM-DDTHH:MM:SS" formats.

#toHtmlMonth Source

toHtmlMonth :: PlainYearMonth -> String

Format a PlainYearMonth for <input type="month">.

Produces "YYYY-MM" (e.g. "2024-03").

#fromHtmlMonth Source

fromHtmlMonth :: String -> Maybe PlainYearMonth

Parse a value from <input type="month">.

Accepts "YYYY-MM" format.