GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - time-loop/parse-duration: convert a human readable duration to ms

This repository was archived by the owner on Sep 4, 2023. It is now read-only.
BranchesTags
Open more actions menu
 
 

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
History.md
History.md
 
 
License
License
 
 
Readme.md
Readme.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 
test.js
test.js
 
 

Repository files navigation

parse-duration

convert a human readable duration to ms

Installation

npm install parse-duration-clickup

then in your app:

var parse = require("parse-duration-clickup");

API

parse(str, defaultUnits)

convert str to ms

var ns = parse("1ns"); // => 1 / 1e6
var μs = parse("1μs"); // => 1 / 1000
var ms = parse("1ms"); // => 1
var s = parse("1s"); // => ms * 1000
var m = parse("1m"); // => s * 60
var h = parse("1h"); // => m * 60
var d = parse("1d"); // => h * 24
var w = parse("1w"); // => d * 7
var y = parse("1y"); // => d * 365.25

It can also handle basic compound expressions

parse("1hr 20mins"); // => 1 * h + 20 * m

whitespace

parse("1 hr 20 mins"); // => 1 * h + 20 * m

comma seperated numbers

parse("27,681 ns"); // => 27681 * ns

And most other types of noise

parse("running length: 1hour:20mins"); // => 1* h + 20 * m

You can even use negatives

parse("2hr -40mins"); // => 1 * h + 20 * m

And exponents

parse("2e3s"); // => 2000 * s

Available unit types are:

  • nanoseconds (ns)
  • microseconds (μs)
  • milliseconds (ms)
  • seconds (s, sec)
  • minutes (m, min)
  • hours (h, hr)
  • days (d)
  • weeks (w, wk)
  • months
  • years (y, yr)

And its easy to add more

About

convert a human readable duration to ms

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.