I have a calender and has following two scenarios:
case - 1
- current_month = 8 (aug)
- end_month = 10 (oct)
- current_year = 2017
- end_year = 2017
case - 2
- current_month = 8 (aug)
- end_month = 2 (feb)
- current_year = 2017
- end_year = 2018
When I click next month it should move only until "end_month". What should be the condition to satisfy both the cases:
if(condition)
alert("Move to next month");
else
alert("condition fail");
I have tried comparing start and end date objects, But I'm able to move one more month extra, which should not happen. I have used the following conditions:
- cal_date = Tue Aug 01 2017 23:58:33 GMT+0530 (India Standard Time)
$scope.edate = Wed Nov 15 2017 00:00:00 GMT+0530 (India Standard Time)
if (cal_date.getMonth() > $scope.edate.getMonth() + 1 || cal_date.getMonth() == $scope.edate.getMonth() || $scope.edate.getFullYear() <= new Date().getFullYear()) if (cal_date.getMonth() > $scope.edate.getMonth() || cal_date.getMonth() == $scope.edate.getMonth()) if (cal_date.getTime() < new Date(new Date($scope.edate) - 1)) { if (cal_date < $scope.edate) {