Skip to main content

@std/datetime@0.225.2
Built and signed on GitHub Actions

UNSTABLE: Utilities for dealing with Date objects

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
100%
Published
3 months ago (0.225.2)

Utilities for dealing with Date objects.

import { dayOfYear, isLeap, difference, HOUR, MINUTE, SECOND } from "@std/datetime";
import { assertEquals } from "@std/assert";

assertEquals(dayOfYear(new Date("2019-03-11T03:24:00")), 70);
assertEquals(isLeap(1970), false);

const date0 = new Date("2018-05-14");
const date1 = new Date("2020-05-13");
assertEquals(difference(date0, date1).years, 1);

assertEquals(HOUR / MINUTE, 60);
assertEquals(MINUTE / SECOND, 60);
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@std/datetime

Import symbol

import * as datetime from "@std/datetime";

---- OR ----

Import directly with a jsr specifier

import * as datetime from "jsr:@std/datetime";

Add Package

npx jsr add @std/datetime

Import symbol

import * as datetime from "@std/datetime";

Add Package

yarn dlx jsr add @std/datetime

Import symbol

import * as datetime from "@std/datetime";

Add Package

pnpm dlx jsr add @std/datetime

Import symbol

import * as datetime from "@std/datetime";

Add Package

bunx jsr add @std/datetime

Import symbol

import * as datetime from "@std/datetime";