Simple parsing of written durations
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
test
.gitignore
.travis.yml
README.md
index.js
package.json

README.md

timecop

Simple parsing of written durations

Build Status

example

var timecop = require('../index.js');

var duration = timecop('Every 2 seconds and 300 milliseconds').milliseconds();

var interval = setInterval(function() {
  console.log('I am logging every 2.3 seconds');
}, duration);

timecop checks for milliseconds, seconds, minutes, hours, days and weeks

timecop('1 week, 2 days, 3 hours, 4 minutes, 5 seconds and 6 milliseconds');

and outputs to any of those same units

var duration = timecop('2 days');

duration.milliseconds(); // 172800000
duration.seconds(); // 172800
duration.minutes(); // 2880
duration.hours(); // 48
duration.days(); // 2
duration.weeks(); // 0.29

install

With npm do:

npm install timecop

license

MIT