Звучит так, как будто вы хотите использовать Datejs . Это очень круто.
Если вы используете Datejs, вот как вы могли бы это сделать:
function expandRange(start, end) // start and end are your two Date inputs
{
var range;
if (start.isBefore(end))
{
start = start.clone();
range = [];
while (!start.same().day(end))
{
range.push(start.clone());
start.addDays(1);
}
range.push(end.clone());
return range;
}
else
{
// arguments were passed in wrong order
return expandRange(end, start);
}
}
ех. для меня:
expandRange(new Date('2010-08-31'), new Date('2010-09-02'));
возвращает массив с 3 объектами Date:
[Tue Aug 31 2010 00:00:00 GMT-0400 (Eastern Daylight Time),
Wed Sep 01 2010 00:00:00 GMT-0400 (Eastern Daylight Time),
Thu Sep 02 2010 00:00:00 GMT-0400 (Eastern Daylight Time)]