getDaysInYear.js
function getDaysInYear(y,d,t,r){
for((t=new Date(y,r=[])).setDate(t.getDate()+(7+d-t.getDay())%7);t.getFullYear()==y;t.setDate(t.getDate()+7))r.push(new Date(t));return r
}
console.log( getDaysInYear(2014,2) );
function getDaysInYear(year,day){
var d=new Date(year,0), dates=[];
d.setDate(d.getDate()+(7+day-d.getDay())%7);
while(d.getFullYear()===year){
dates.push(new Date(d));
d.setDate(d.getDate()+7);
}
return dates;
}