Comparing version 0.1.4 to 0.1.5
@@ -115,5 +115,10 @@ var difference = require('lodash.difference'); | ||
dates: function(start, end) { | ||
if (start > end) { | ||
var temp = end; | ||
end = start; | ||
start = temp; | ||
} | ||
var result = [] | ||
, diff = instadate.differenceInDays(start, end); | ||
for (var i = 0; i < diff; i++) { | ||
, diff = instadate.differenceInDates(start, end); | ||
for (var i = 0; i <= diff; i++) { | ||
result.push(instadate.addDays(start, i)); | ||
@@ -120,0 +125,0 @@ } |
{ | ||
"name": "instadate", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "instadate.js", |
@@ -160,9 +160,21 @@ var test = require('tape'); | ||
test('dates array', function (t) { | ||
test('dates', function (t) { | ||
var start = new Date('Mon Jan 18 2016 13:07:17 GMT+0200 (EET)') | ||
, end = instadate.noon(new Date('Thu Jan 21 2016 13:07:17 GMT+0200 (EET)')); | ||
var dates = instadate.dates(start, end); | ||
t.equal(dates.length, 2); | ||
t.equal(dates.length, 4); | ||
t.ok(instadate.equal(dates[0], start)); | ||
t.equal(dates[1].toString(), instadate.addDays(start, 1).toString()); | ||
t.equal(dates[2].toString(), instadate.addDays(start, 2).toString()); | ||
t.equal(dates[3].toString(), instadate.addDays(start, 3).toString()); | ||
var start = instadate.noon(new Date('Thu Jan 21 2016 13:07:17 GMT+0200 (EET)')) | ||
, end = new Date('Mon Jan 18 2016 13:07:17 GMT+0200 (EET)'); | ||
var dates = instadate.dates(start, end); | ||
t.equal(dates.length, 4); | ||
t.ok(instadate.equal(dates[0], end)); | ||
t.equal(dates[1].toString(), instadate.addDays(end, 1).toString()); | ||
t.equal(dates[2].toString(), instadate.addDays(end, 2).toString()); | ||
t.equal(dates[3].toString(), instadate.addDays(end, 3).toString()); | ||
t.end(); | ||
@@ -169,0 +181,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25514
606