import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { date } = decoder;
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
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)