Package: effect
Module: SchemaTransformation
Decodes a string into a Date and encodes a Date back to a string.
When to use
Use when you need a schema transformation to parse date strings from APIs or user input.
Details
Decoding creates a Date from the string like new Date(s). Encoding
converts the Date to an ISO string like date.toISOString(), returning
"Invalid Date" for invalid dates.
Example (Converting a string to a Date)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.String.pipe(
Schema.decodeTo(Schema.Date, SchemaTransformation.dateFromString)
)
See
dateFromMillisdateTimeUtcFromStringSignature
declare const dateFromString: Transformation<Date, string, never, never>
Since v4.0.0