Socket
Socket
Sign inDemoInstall

durhuman

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

durhuman

Parse human readable time duration strings to numbers


Version published
Weekly downloads
48
increased by37.14%
Maintainers
1
Weekly downloads
 
Created
Source

Human Duration

I am tired of seeing exp: 22220201838. What does that mean to a human? This tiny package let's you write '23 days' and parse it to into a number.

Install

yarn add durhuman

Includes a Duration type that can be really helpful if you're using Typescript.

Usage

By default parse will parse as seconds. Pass the optional unit argument to have it convert to a differnt unit of time.

import dur, { Duration } from 'durhuman'

dur('1 second')
// 1

dur('23 minutes')
// 1,380

dur('23 minutes', 'milliseconds')
// 1,380,000

dur('2 days')
// 172,800

dur('2 days', 'hours')
// 48

FAQs

Package last updated on 28 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc