Skip to main content

JavaScript date utility library for Temporal API

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (0.3.3)

vremel

JavaScript date utility library for Temporal API inspired by date-fns.

  • Contains only pure functions, supports tree-shaking by default.
  • Supports every types of Temporal API (Instant, ZonedDateTime, PlainDate...) with strict TypeScript definition.
  • Handles timezones and calendars strictly.
  • Works fine with any polyfills. You don't have to even load a polyfill globally.

Install

npm install vremel
# or from JSR
deno add @fabon/vremel

Usage

import { compareDesc } from "vremel";
import { isEqual } from "vremel/duration"; // utility functions for Temporal.Duration

[
	Temporal.PlainDate.from("2024-01-01"),
	Temporal.PlainDate.from("2024-02-01"),
	Temporal.PlainDate.from("2023-11-30"),
]
	.sort(compareDesc)
	.map((d) => d.toString()); // [ '2024-02-01', '2024-01-01', '2023-11-30' ]

isEqual(
	Temporal.Duration.from({ hours: 3 }),
	Temporal.Duration.from({ hours: 3 }),
); // true

vremel works fine with any polyfills. Also it works even if Temporal doesn't exist in the global scope.

import { Temporal } from "temporal-polyfill";
// or
import { Temporal } from "@js-temporal/polyfill";
import { isAfter } from "vremel";

isAfter(
	Temporal.PlainDate.from("2024-01-01"),
	Temporal.PlainDate.from("2024-02-01"),
); // false

Docs

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @fabon/vremel

Import symbol

import * as mod from "@fabon/vremel";

Add Package

npx jsr add @fabon/vremel

Import symbol

import * as mod from "@fabon/vremel";

Add Package

yarn dlx jsr add @fabon/vremel

Import symbol

import * as mod from "@fabon/vremel";

Add Package

pnpm dlx jsr add @fabon/vremel

Import symbol

import * as mod from "@fabon/vremel";

Add Package

bunx jsr add @fabon/vremel

Import symbol

import * as mod from "@fabon/vremel";