The code is very simple and there is no more nonsense. Just present the code:
The code copy is as follows:
/**
* What week is the realization of the current date? Then push forward and backward
* js array saves the data before and after the current date (5 weeks in total)
* */
var initSearchMajorChanges = function(){
//Implement the current date in which week is the current year, and then push forward and backward for a few weeks. The js array saves the first and next two weeks of the current date (a total of five weeks of data)
var vv='2015-02-07';
var vNowDate=moment(new moment(vv).format("YYYY-MM-DD"));//.add('month',0).add('days',-1);
var vWeekOfDay=moment(vNowDate).format("E");//File the week of this week
var vWeekOfDays=7-vWeekOfDay-1;
var vStartDate=moment(vNowDate).add('days',vWeekOfDays);
var vEndDate=moment(vNowDate).add('days',-vWeekOfDay);
var vStartDateNew=moment(vStartDate).add('days',7*$scope.gWeeks);
var vEndDateNew=moment(vEndDate).add('days',-(7*$scope.gWeeks));
//var vYearAndWeek=moment(vStartDate).format("YYYY")+'-'+moment(vStartDate).format("WW");
searchMajorChanges(vStartDateNew,vEndDateNew);
}
need:
The js array saves the first and next two weeks of the current date week (a total of five weeks of data). The above is the core code!
The usage method is also very simple, I hope you like it.