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

ms-time-tools

v1.1.0

Published

ms-time-tools is a powerful Node.js module that allows you to easily manage time.

Downloads

13

Readme

About

ms-time-tools is a powerful Node.js module that allows you to easily manage time.

Features

Installation

npm install --save ms-time-tools

Examples

const  mtt = require('ms-times-tools'); // Import the module

Convert from milliseconds

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|number|❌||Time in milliseconds to convert into string| |format|string|✅|Y-MO-W-D-H-M-S-MS|Format and order of time returned| |lang|string|✅|en|Language of time unities| |long|boolean|✅|false|Returns the whole word (not abbreviations)| |separator|string|✅|, |Separators of time values| |suppressTag|boolean|✅|false|Returns time without unities| |valueNull|boolean|✅|false|Removes values equal to zero|

Some usage examples:

mtt.stringifyTime(61000); // 1m, 1s

mtt.stringifyTime(
    617780000,
	{
	    format: 'Y-MO-W-D-H-M-S-MS',
		lang: 'en',
		long: true
	}
); // 1 week, 3 hours, 36 minutes, 20 seconds

mtt.stringifyTime(
	5100300,
	{
		valueNull: true,
		separator: '/'
	}
); // 0y/0mo/0w/0d/1h/25m/0s/3ms

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Convert from string

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|string|❌||Time in string to convert into milliseconds| |msOff|boolean|✅|false|Returns time in seconds instead of milliseconds|

Some usage examples:

mtt.parseTime('1 minute 1 second'); // 61000

mtt.parseTime(
    '2h 5m',
	{ msOff: true }
); // 7500

mtt.parseTime('1 month 2d 4hours'); // 187260000

mtt.stringifyTime(
	35071,
	{ suppressTag: true }
); // 35, 71

Format time

Here is the list of all the arguments available: |Parameter|Type|Optional|Default|Description| |:-:|:-:|:-:|:-:|:-:| |time|string|❌||Time to format| |format|string|✅|y YYYY, mo MMMM, d DD H:M:S.MS|Format and order of time returned, check here for more information| |lang|string|✅|en|Language of time unities| |long|boolean|✅|false|Returns the whole word (not abbreviations)| |suppressTag|boolean|✅|false|Returns time without unities| |valueNull|boolean|✅|false|Removes values equal to zero|

Some usage examples:

mtt.formatTime(654686145655); // 20 years, 8 months, 29 days 01:00:25.655

mtt.formatTime(
    65364,
    { format: 'M:S.MS' }
); // 01:05.364

mtt.formatTime(
    449155098,
    { format: 'D DD, h:M:S.ms' }
); // 05 days, 4:45:55.98