JSは、指定された日付に基づいて、その日付がある月曜日と日曜日を取得します.
9883 ワード
/**
* @param (yyyy-mm-dd)
* @author QC
* @date 2018-03-15
* */
getMonDayAndSunDay(datevalue) {
let dateValue = datevalue;
let arr = dateValue.split("-");
// -1 0 Date
let date = new Date(arr[0], arr[1] - 1, arr[2]);
let dateOfWeek = date.getDay();// (0~6-- )
let dateOfWeekInt = parseInt(dateOfWeek, 10);//
if (dateOfWeekInt == 0) {//
dateOfWeekInt = 7;
}
let aa = 7 - dateOfWeekInt;//
let temp2 = parseInt(arr[2], 10);// 10 , 08 09 0
let sunDay = temp2 + aa;//
let monDay = sunDay - 6;//
let startDate = new Date(arr[0], arr[1] - 1, monDay);
let endDate = new Date(arr[0], arr[1] - 1, sunDay);
let sm = parseInt(startDate.getMonth()) + 1;// +1 0
let em = parseInt(endDate.getMonth()) + 1;
// alert(" :"+startDate.getFullYear()+"-"+sm+"-"+startDate.getDate());
// alert(" :"+endDate.getFullYear()+"-"+em+"-"+endDate.getDate());
let start = startDate.getFullYear() + "-" + sm + "-" + startDate.getDate();
let end = endDate.getFullYear() + "-" + em + "-" + endDate.getDate();
let result = [];
result.push(start);
result.push(end);
return result;
},
getDate() {
let dt = new Date()
let start = new Date(dt.getFullYear(), dt.getMonth(), 1)
let start_ = new Date(this.getMonDayAndSunDay(start.Format('yyyy-MM-dd'))[0])
let end = new Date(dt.getFullYear(), dt.getMonth() + 1, 5)
let end_ = new Date(this.getMonDayAndSunDay(end.Format('yyyy-MM-dd'))[1])
this.changeMonth(start_, end_);
},