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 🙏

© 2025 – Pkg Stats / Ryan Hefner

s2hms

v3.0.0

Published

convert seconds to HMS (or) to hours, minutes, seconds explicitly.

Downloads

119

Readme

s2hms

npm example workflow example workflow

convert seconds to HMS (or) to hours, minutes, seconds explicitly.

Install

npm install s2hms

Usage

contains two types of modules :

  1. s2hms
  2. s2h, s2m, s2s

1) s2hms : converts seconds to 'hms' format.

takes two arguments : seconds (number) , options (object optional)

import { s2hms } from "s2hms";

s2hms(4342);
//  01:12:22

s2hms(1432);
//  00:23:52

s2hms(64567, { format: "short" });
//  17h:56m:07s

s2hms(432, { format: "long" });
//  07minutes:12seconds

s2hms(8573, { format: "long", separator: "__" });
//  02hours__22minutes__53seconds

options

| key | val | type | default val | | --------- |------------------------------------------------------| -------- |-----------------| | format | 'long', 'short', 'standard | string | 'standard' | | separator | any string char ':' , '+' , '=' , '_' ,'-' , etc... | string | ':' |

example:

with separator: '/' and format: 'short'

s2hms(983, { format: "short", separator: "/" });
// => 16m/23s

2) ( s2h, s2m, s2s ) : converts seconds to hours, minutes, seconds explicitly.

takes two arguments : seconds (number) , options (object optional)

import { s2h, s2m, s2s } from "s2hms";

s2h(43434);
//  12.1

s2m(9832, { format: "short" });
//  163.9 m

s2m(98907, { format: "long" });
//  1648.5 minutes

s2s(9832, { format: "short" });
//  9832 s

options

| key | val | type | default val | | -------- |----------------------------| --------- |-----------------| | format | 'long', 'short', 'standard' | string | 'standard' | | fallback | true, false | boolean | false |

when fallback is set to true, conversion auto downgrades to next unit if the resulting value is less than 1 (one),

examples:

without fallback

s2h(983, { format: "short" });
//  0.3 h

with fallback set to true

s2h(983, { format: "short", fallback: true });
//  16.4 m

without fallback

s2m(46, { format: "long" });
//  0.8 minute

with fallback set to true

s2m(46, { format: "long", fallback: true });
//  46 seconds

note: fallback can be used only when a format is specified , if no format is specified and fallback is set to true , it will throw an error, this is to prevent confusion of resulting value's unit type.

s2h(634, { fallback: true });
//   Error: option'fallback:true' can only be used when a format is specified

License

MIT