object representing / normalizing date ranges
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
Makefile
Readme.md
component.json
example.js
index.js
package.json

Readme.md

date-range

DateRange component

Installation

$ component install component/date-range

Example

var DateRange = require('./');

var now = new Date;
var future = new Date(Date.now() + 60000 * 5);
var range = new DateRange(now, future);

API

DateRange()

Initialize a new DateRange from one date to another. If one date is larger than the other they are normalized so that .from() is always the smallest date.

DateRange#from([date]:Date)

Set / get from date.

DateRange#to([date]:Date)

Set / get to date.

DateRange#diff()

Return diff in milliseconds

DateRange#toJSON()

Return JSON representation.

DateRange#equals(other:DateRange)

Check if this range is identical to other.

DateRange#toString()

Return string representation.

License

MIT