I am in need of a function that can provide me with all the occurrences of a specific day within the current month. I have the first and last day of the month, as well as the length of the month. While I have come across functions that offer the next occurrence of a day, I am looking for a solution that can display all occurrences. I believe this may involve a loop, and I am currently working on it. Any assistance would be greatly appreciated.
$scope.recurrenceFields.by_year_day=$filter('date')($scope.fields.times.dateStart, 'yyyy');
$scope.recurrenceFields.by_month=$filter('date')($scope.fields.times.dateStart, 'M');
var correntDay = new Date();
var lastDayOfMonth = new Date(correntDay.getFullYear(), correntDay.getMonth()+1, 0);
var firstDayOfMonth = new Date(correntDay.getFullYear(), correntDay.getMonth(), 1);
function daysInMonth(month,year) {
return new Date($filter('date')($scope.fields.times.dateStart, 'yyyy'), $scope.recurrenceFields.by_month, 0).getDate();
}