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 🙏

© 2024 – Pkg Stats / Ryan Hefner

secondjs

v0.0.2

Published

A second conversion utility

Downloads

307

Readme

secondjs

A simple second conversion utility. It takes an Number (seconds) and allows you to convert that to minutes, hours, days, weeks and milliseconds.

Install

installation is simple using npm.

npm i secondjs --save

Usage

Basic example

If you would like to get started quickly, use the following as an example:

const secondjs = require('secondjs')

// get the individual minutes since some other time
const seconds = 12345
console.log(`Minutes: ${secondjs(seconds).minutes}`)

// Outputs: Minutes: 205
Advanced example

A simple API is provided by example:

const secondjs = require('secondjs')

const seconds = 10000000
const test = secondjs(seconds)

console.log(`seconds: ${seconds}`)
console.log(`minutes: ${test.minutes}`)
console.log(`hours: ${test.hours}`)
console.log(`days: ${test.days}`)
console.log(`weeks: ${test.weeks}`)
console.log(`round: ${test.round()}`)
console.log(`string: ${test}`)
console.log(`It has been ${secondjs(process.uptime()).round()} since this process started!`)

/* Outputs:
seconds: 10000000
minutes: 166666
hours: 2777
days: 115
weeks: 16
round: 16 weeks
*/
Round

The round feature will use the largest time-value available by default.

const secondjs = require('secondjs')
console.log(secondjs(10000).round())
// Outputs: 2 hours

You can also pass in an override and make sure the value conforms to a specific measurement:

const secondjs = require('secondjs')
console.log(secondjs(10000).round('minutes'))
// Outputs: 166 minutes

The following arguments are allowed:

  • milliseconds
  • seconds
  • minutes
  • hours
  • days
  • weeks
Milliseconds

We also support converting milliseconds:

const { millisecondjs } = require('secondjs')
console.log(`${millisecondjs(Date.now())} since 1 January 1970 00:00:00 UTC`)
// Output (will vary): 1510677893 seconds since 1 January 1970 00:00:00 UTC

To do

Since this is still in "early-access" I wanted to make clear some goals:

  • [ ] Add support for months
    • Currently do not support this as it is non static (28-31 days)
  • [ ] Add support for years
    • Same as month support
  • [ ] Optimize speed and memory
    • Mainly supporting the caching of values.

License

MIT