Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
duration-parser
Advanced tools
Readme
parse time durations written in plain english
It's a function that parses a duration string and returns the number of milliseconds that duration represents.
var parseDuration = require(`duration-parser`);
parseDuration('1 second'); // 1000
parseDuration('2 seconds'); // 2000
parseDuration('3.4s'); // 3400
parseDuration('1 minute 9 seconds'); // 69000
parseDuration('1 minute - 10 seconds'); // 50000
parseDuration('-1 minute + 10 seconds'); // -50000
parseDuration('-1 minute 10 seconds'); // -70000
It understands the following time constructs and abbreviations.
milliseconds
, millisecond
, ms
seconds
, second
, secs
, sec
, s
minutes
, minute
, mins
, min
, m
hours
, hour
, hrs
, hr
, h
days
, day
, d
weeks
, week
, wks
, wk
, w
+
/ -
and order of operations+
and -
operators perform addition and subtraction as expected.
Concatenating time measurements together (with or without whitespace) will perform addition.
'1h3s' == '1h + 3s' == '1 hour 3 seconds'
Concatenation has higher precedence than the +
or -
operators, so:
'1 week - 2 days 6 hours' == '1 week - (2 days + 6 hours)'
(parenthesis are not currently supported)
git status
).2.13
or later, or 3.1
or later (npm --version
, npm i npm@latest
).cut-release
installed (npm i -g cut-release
).cut-release
.FAQs
parse time durations written in plain english
The npm package duration-parser receives a total of 172 weekly downloads. As such, duration-parser popularity was classified as not popular.
We found that duration-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.