Hyperlinkv0.8.0-beta.28

SchemaGetter

SchemaGetter.Datefunctioneffect/SchemaGetter.ts:792
<E extends string | number | Date>(): Getter<Date, E>

Coerces a value to a Date using new Date(input).

When to use

Use when you need a schema getter to coerce a present string, number, or existing date object into a new date object.

Details

  • Delegates to new globalThis.Date(input).
  • Does not validate the result — may produce an invalid Date.

Example (Coercing to a Date)

import { SchemaGetter } from "effect"

const toDate = SchemaGetter.Date<string>()
// Getter<Date, string>
export function Date<E extends string | number | Date>(): Getter<Date, E> {
  return transform((u) => new globalThis.Date(u))
}
Referenced by 2 symbols