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

@nathanielanum13/djuration

v1.0.0

Published

Djuration is built to provide frequently used time functions and properties at your disposal

Readme

Installation

Djuration is built to provide frequently used time functions and properties at your disposal

You can add Djuration to your project using 3 different approaches

  1. Import it using script <script></script> on the page
  2. Download the JavaScript file from GIT and import it
  3. Install it using npm

Release Notes

Current release version 1.0.0

Detailed release notes for each version are available on GitHub.

script

You can use Djuration with:

<script src="djuration.js"></script>

npm

Use npm to install the Djuration by:

$ npm install djuration

methods, properties and usage

Djuration is a class based library that accepts one constructor argument of type number. i.e duration in milliseconds

  • methods

    toMilliseconds()

      /**
       * @param {number} seconds
       * `Converts seconds to milliseconds`
       */

    formatInSecond()

      /**
       * @param {number} num
       * `Converts milliseconds to a formated second. e.g 1 second`
       */

    formatInMinute()

      /**
       * @param {number} num
       * `Converts milliseconds to a formated minute. e.g 2 minutes`
       */

    formatInHour()

      /**
       * @param {number} num
       * `Converts milliseconds to a formated hour. e.g 1 hour`
       */

    formatInDay()

      /**
       * @param {number} num
       * `Converts milliseconds to a formated day. e.g 21 days`
       */

    formatInWeek()

      /**
       * @param {number} num
       * `Converts milliseconds to a formated week. e.g 2 weeks`
       */

    formatAll(separator)

      /**
       * @param {string} separator
       * `Converts milliseconds to e.g 1 week 3 days 11 hours`
       */
  • getters

    toSeconds Returns an object with class constructor argument in seconds and the remaining in seconds

    toWeeks Returns an object with class constructor argument in weeks and the remaining in seconds

    toDays Returns an object with class constructor argument in days and the remaining value in seconds

    toHours Returns an object with class constructor argument in hours and the remaining in seconds

    toMinutes Returns an object with class constructor argument in minutes and the remaining in seconds

    getTrans Outputs Translations for Duration formats

  • setters

    setWeekTrans(preferredTrans)

      /**
       * @param {string} preferredTrans
       */

    setDayTrans(preferredTrans)

      /**
       * @param {string} preferredTrans
       */

    setHourTrans(preferredTrans)

      /**
       * @param {string} preferredTrans
       */

    setMinuteTrans(preferredTrans)

      /**
       * @param {string} preferredTrans
       */

    setSecondTrans(preferredTrans)

      /**
       * @param {string} preferredTrans
       */
  • usage

    Step 1 :: import the file in your project

    import Duration from "djuration"

    Step 2 :: Example

    const inProgress = new Date("Tue Aug 17 2021 07:01:05")
    const done = new Date("Sun Aug 29 2021 01:15:23")
    
    const timeTaken = done - inProgress // in milliseconds
    const duration = new Duration(timeTaken)
    
    console.log(duration.formatAll(" "))
    onsole.log(duration.formatInDay(/* Optional param */))
    
    // Changing Translations
    // i.e week = wk, hour = hr, minute = min, second = sec
    
    duration.setWeekTrans = "wk" // Singular
    duration.setHourTrans = "hr" // Singular
    duration.setMinuteTrans = "min" // Singular
    duration.setSecondTrans = "sec" // Singular
    
    console.log(duration.formatAll(" - "))
    
    

    Output

    1 week 4 days 18 hours 14 minutes 18 seconds
    11 days
    
    #after translations have been set
    
    1 wk - 4 days - 18 hrs - 14 mins - 18 secs