Skip to main content
Module

x/fun/decoder.ts>date

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function date
import { date } from "https://deno.land/x/fun@v.2.0.0-alpha.11/decoder.ts";

A Decoder that attempts to decode a Date using new Date(value). If the process of calling new Date throws or the getTime method on the new date object returns NaN, then a failure is returned. If a Date can be derived from the object then a Date object is returned.

Examples

Example 1

import * as D from "./decoder.ts";

const result1 = D.date(null); // Left(DecodeError)
const result2 = D.date(Date.now()); // Right(Date)
const result3 = D.date("1990"); // Right(Date)
const result4 = D.date(new Date()); // Right(Date)

Parameters

a: unknown