Skip to main content
Home

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
It is unknown whether 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
a year ago (0.1.2)
method HHMM.prototype.intervals
HHMM.prototype.intervals(
to: ,
interval: ,
): Generator<HHMM>

Generate all intervals between a start time and end time. If end is less than start, generate all intervals between start and end + 24h

Examples

Example 1

for (const interval of "08:00"[HM].intervals("12:00", "00:15")) {
  // 1. "08:00"
  // 2. "08:15"
  // 3. "08:30"
  // ...
  // n. "12:00"
}

Example 2

const from = "08:00"
const to = "12:00"
const intervals = [...from[HM].intervals(to, "00:15")]

Example 3

const from = "20:00"
const to = "02:00"
for (const interval of from[HM].intervals(to, "00:15")) {
  // 1. "20:00"
  // 2. "20:15"
  // 3. "20:30"
  // ...
  // n. "26:00"
}

Parameters

interval:

Return Type

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:@revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";
or

Import directly with a jsr specifier

import { HHMM } from "jsr:@revosw/hhmm";

Add Package

pnpm i jsr:@revosw/hhmm
or (using pnpm 10.8 or older)
pnpm dlx jsr add @revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";

Add Package

yarn add jsr:@revosw/hhmm
or (using Yarn 4.8 or older)
yarn dlx jsr add @revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";

Add Package

vlt install jsr:@revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";

Add Package

npx jsr add @revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";

Add Package

bunx jsr add @revosw/hhmm

Import symbol

import { HHMM } from "@revosw/hhmm";