create timespans objects for using with native js dates


Timespan is a chainable object you can use to represent a span of time for interacting with the js Date object in node.js, and the browser.

Install via npm

    npm install timespanjs

Use in browser

    <script src="bin/timespan.min.js"></script>

Import into your file and create a timespan

   var Timespan = require('timespanjs');
   var ts = new Timespan();
   //pass it a starting time 
   var ts = new Timespan(1234);
   //pass it another timespan object 
   var ts1 = new Timespan(1234);
   var ts2 = new Timespan(ts1);

Add time


Add to a date

   var date = new Date();
   date = ts.addToDate(date);

display as a string

   var ts = new Timespan().addHour(2).addMinute(1).addSecond(13);
   //returns '2 hours 1 minute 13 seconds' 

Timespan is very useful for intervals and timeouts

    var everyThirtyMinutes = new Timespan().addMinutes(30);
    var intervalId = everyThirtyMinutes.setInterval(function(){
    var timeoutId = everyThirtyMinutes.setTimeout(function(){