The code is very simple no more nonsense, directly to the code:
Copy Code code as follows:
/**
* Implementing the current date is the week ordinal of the year, then forward and backward for a few weeks
* JS Array to save the current date before and after two weeks (a total of five weeks of data)
* */
var initsearchmajorchanges = function () {
Implement the current date is the week of the year, then forward and backward for a few weeks, JS array to save the current date before and after two weeks (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"); calculate the week of the 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);
}
Demand:
JS Array saves the current date week before and after two weeks (a total of five weeks of data), the above is the core code!
The use of the method is also very simple, I hope you can enjoy.