Skip to main content
Home

Library for dealing with Durations. Uses Temporal Polyfill.

This package works with Node.js, BunIt is unknown whether this package works with Deno
This package works with Node.js
It is unknown whether this package works with Deno
This package works with Bun
JSR Score
100%
Published
2 months ago (0.1.9)

Duration.js


A library for handling durations that uses the Temporal proposal polyfill.

This is a fork of Duration.js by icholy based on the golang_compatible branch.

Example

import { Duration, DiscordTimestamp } from '@shanecaf/duration-js';

const duration = new Duration('1w 2d');

console.log(duration.endDate()); // Outputs a Date object.

//Discord Timestamps:
console.log(duration.toDiscordTimestamp(DiscordTimestamp.LongDateTime)); //Outputs <t:[date_in_epoch_sec]:F> for Discord.

Tests

Since this is a work in progress, there are no tests yet.

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:@shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";
or

Import directly with a jsr specifier

import * as duration_js from "jsr:@shanecaf/duration-js";

Add Package

pnpm i jsr:@shanecaf/duration-js
or (using pnpm 10.8 or older)
pnpm dlx jsr add @shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";

Add Package

yarn add jsr:@shanecaf/duration-js
or (using Yarn 4.8 or older)
yarn dlx jsr add @shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";

Add Package

vlt install jsr:@shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";

Add Package

npx jsr add @shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";

Add Package

bunx jsr add @shanecaf/duration-js

Import symbol

import * as duration_js from "@shanecaf/duration-js";