This release is 1 version behind 0.1.2 — the latest version of @revosw/hhmm. Jump to latest
Utility for doing math on strings in the format "hh:mm", such as adding, subtracting, intersection testing and modulo
This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers




JSR Score
94%
Published
a year ago (0.1.1)
Handle HH:MM calculations with ease
This library makes it easy to do the following:
- Adding and subtracting times
// Using class instances const add1 = new HHMM("08:00").add("01:00") // ^? = HHMM { minute = 540 } const sub1 = new HHMM("08:00").subtract("00:15") // ^? = HHMM { minute = 465 } // Using the HM symbol property const add2 = "08:00"[HM].add("09:00") const sub2 = "08:00"[HM].subtract("09:00")
- Divide
// Using class instances const newTime = new HHMM("08:00").subtract("09:00") // Using the HM symbol property const newTime = "08:00"[HM].subtract("09:00")
Symbol property mode
You will suffer if you try to
It is tiresome having to create class instances all the time for the simplest things.
const from = new HHMM("08:00") const to = new HHMM("09:00") if (from.lt(to)) { // from < to } if (new HHMM("08:00") < new HHMM("09:00"))
Problems with structuredClone()
Since class instances
Problems with React
Problems with TanStack Query
The query cache does not like
While it's possible to use the
Add Package
deno add jsr:@revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";
Import directly with a jsr specifier
import * as hhmm from "jsr:@revosw/hhmm";
Add Package
pnpm i jsr:@revosw/hhmm
pnpm dlx jsr add @revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";
Add Package
yarn add jsr:@revosw/hhmm
yarn dlx jsr add @revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";
Add Package
vlt install jsr:@revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";
Add Package
npx jsr add @revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";
Add Package
bunx jsr add @revosw/hhmm
Import symbol
import * as hhmm from "@revosw/hhmm";