npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iso8601-interval

v1.0.2

Published

A time duration convert library based on tagged template syntax

Downloads

21

Readme

iso8601-interval

Node.js CI npm GitHub npm bundle size GitHub top language Coverage Status GitHub issues

A time duration convert library based on tagged template syntax.

The ISO8601 duration format

Durations in ISO8601 comes in two formats:

  • PnYnMnDTnHnMnS - P<date>T<time> The n is replaced by the value for each of the date and time elements that follow the n.
  • PnW - the week format.

Check out the details on Wikipedia

Install

npm install iso8601-interval

then import to your js module

import { duration, dur, period, per, interval, invl } from "time-interval";

Usage

  • duration or dur

    Create a Duration Object to represent the number of milliseconds elapsed.

    It is allowed to process data in the format of PTnHnMnS, the input number can be decimals, but the number of milliseconds obtained will be rounded to an integer.

    dur`PT1S`.ms; // => 1000
    dur`PT${1/3}S`.ms; // => 333
    dur`PT1M`.sub(dur`PT1S`).s; // => 59
    dur`PT24H`.toDate(new Date(2021, 0, 1)); // => Date 2020-01-02
    dur`PT10S`.s == duration.ofSeconds(10).s;
    // Make Timer duration param easier to read
    setTimeout(..., dur`PT1S`.ms);
  • period or per

    Create a Period Object to represent the duration of Date.

    It is allowed to process data in the format of PnYnMnWnD (Although this format does not meet the standard), the input number of years and weeks can be decimals, but the number of days and months obtained will be rounded to an integer.

    per`P1Y3D`.getCertainDays(); // => 3
    per`P1Y3D`.getFullMonths(); // => 12
    per`P1M`.toDuration(new Date(2021, 0, 1)).h; // => 28 * 24
    per`P1M`.toDate(new Date(2021, 0, 1)); // => Date 2020-03-01
    period.ofWeeks(1).getCertainDays(); // => 7
  • interval or invl

    Create a Object contains a Duration and a Period.

    It is allowed to process full ISO8601 data in the format of PnYnMnWnDTnHnMnS, input parameters will be passed to duration and period for processing separately.

    invl`P3M2DT60S`.duration.min; // => 1
    invl`P3M2DT60S`.period.getCertainDays(); // => 2
    invl`P3M2DT60S`.period.getFullMonths(); // => 3