Skip to main content
Home

Utility functions for working with dates

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
4 weeks ago (5.0.0)
function isDateCompatible
isDateCompatible(value: unknown): value is

Checks if the given value is compatible with Date.

Examples

Example 1

import { assertEquals } from '@std/assert'

// String is compatible
assertEquals(isDateCompatible('2023-01-15'), true)

Example 2

import { assertEquals } from '@std/assert'

// Date object is compatible
assertEquals(isDateCompatible(new Date()), true)

Example 3

import { assertEquals } from '@std/assert'

// Number (timestamp) is compatible
assertEquals(isDateCompatible(1640000000000), true)
// Other types are not compatible
assertEquals(isDateCompatible(null), false)
assertEquals(isDateCompatible({}), false)

Parameters

value: unknown
  • The value to check.

Return Type

value is
  • True if the value is compatible with Date, false otherwise.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";
or

Import directly with a jsr specifier

import { isDateCompatible } from "jsr:@edouardmisset/date/is-date-compatible.ts";

Add Package

pnpm i jsr:@edouardmisset/date
or (using pnpm 10.8 or older)
pnpm dlx jsr add @edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";

Add Package

yarn add jsr:@edouardmisset/date
or (using Yarn 4.8 or older)
yarn dlx jsr add @edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";

Add Package

vlt install jsr:@edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";

Add Package

npx jsr add @edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";

Add Package

bunx jsr add @edouardmisset/date

Import symbol

import { isDateCompatible } from "@edouardmisset/date/is-date-compatible.ts";