1function sundaysInMonth( m, y ) {
2 var days = new Date( y,m,0 ).getDate();
3 var sundays = [ 8 - (new Date( m +'/01/'+ y ).getDay()) ];
4 for ( var i = sundays[0] + 7; i < days; i += 7 ) {
5 sundays.push( i );
6 }
7 return sundays;
8}
9
10alert( sundaysInMonth( 10,2012 ) ); //=> [ 7,14,21,28 ]
11alert( sundaysInMonth( 10,2012 ).length ); //=> 4
1function mondaysInMonth(m,y) {
2 var days = new Date(y,m,0).getDate();
3 var mondays = new Date(m +'/01/'+ y).getDay();
4 if(mondays != 1){
5 mondays = 9 - mondays;
6 }
7 mondays = [mondays];
8 //console.log(mondays);
9 for (var i = mondays[0] + 7; i <= days; i += 7) {
10 mondays.push(i);
11 }
12 return mondays;
13}