How to run when two for loops are nested

The

backend gives me a start time and an end time, and I need to determine whether it is within this period of time. First, the start and end times may be multiple arrays, and the time period may be multiple data.


{"code":"0","data":{"nowDate":"2018-09-03 14:25:57","isCanUpdate":"0","list":[{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-17"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-18"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-19"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-20"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-21"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-22"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-23"}]},"info":""}

this is the data I have processed

computed:{
              newTimesList(){
                  var day = this.childmessage.day
                  var newTimesList=this.initTimesList.map(function(item) {
                      return +new Date((day+" "+item).replace(/-/g,"/"));
                  })
                  return newTimesList
              },
              getTime(){
                  var timeLength = this.times.length;
                  var timesArray = [];
                  for (var i = 0; i < timeLength; iPP) {
                      var startTime = this.day+" "+this.times[i].startTime;
                      var endTime = this.day+" "+this.times[i].endTime;
                      var startTimeStr = +new Date(startTime.replace(/-/g,"/"));
                      var endTimeStr = +new Date(endTime.replace(/-/g,"/"));
                      var timesList = {
                          startTimeStr:startTimeStr,
                          endTimeStr : endTimeStr
                      }
                      timesArray.push(timesList)
                      return timesArray
                  }
              },
              hasArrange(){
                  var activeArray = []
                  for (var i = 0; i < this.getTime.length; iPP) {
                      for (var j = 0; j < this.newTimesList.length; jPP) {
                          // false
                          // if (this.newTimesList[j]>this.getTime[i]["startTimeStr"]&&this.newTimesList[j]<this.getTime[i]["endTimeStr"]) {
                          //     var thisState = "true"
                          //     activeArray.push(thisState)
                          // }else{
                          //     var thisState = "false"
                          //     activeArray.push(thisState)
                          // }
                      }
                  }
                  return activeArray
              }

I want to judge whether there is an active class based on the subscript of the last data

Jun.06,2021

/ / extended date format (yyyy-MM-dd hh:mm:ss)
function format (date, format) {
var opt = {

  "M+" : date.getMonth()+1,
  "d+" : date.getDate(),
  "h+" : date.getHours(),
  "m+" : date.getMinutes(),
  "s+" : date.getSeconds()
};

if(new RegExp(/(y+)/).test(format)) {
  format = format.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
};

for(var key in opt) {
  if(new RegExp("("+ key +")").test(format)) {
    format = format.replace(RegExp.$1, RegExp.$1.length==1 ? opt[key] : ("00"+ opt[key]).substr((""+ opt[key]).length));
  }
};
return format;

}
/ / Note: res.data is the data returned by the background, that is, the data you provide. Specific expression according to your own.
var data = res.data.data;
var nowDate = data.nowDate,

arrList = data.list;

function isInTime (nowDate, arrList) {

var isInTime = false,
    nowDay = format(new Date(nowDate), "yyyy-MM-dd"),
    nowTime = format(new Date(nowDate), "hh:mm:ss");
for(var i = 0; i < arrList.length; iPP) {
    var day = arrList[i].day;
    if(nowDay == day) {
        var times = arrList[i].times;
        for(var j = 0; j < times.length; jPP) {
            var startTime = times[j].startTime + ":00",
                endTime = times[j].endTime + ":00";
            if(nowTime >= startTime && nowTime <= endTime) {
                isInTime = true;
            }
        }
    }
}
return isInTime;

}


if you look at your sample data, you can assume that list should return nearly a week of working time.
then your requirement should be to determine whether nowDate is within the working time range.
I don't know if I understand this correctly.
if you follow this understanding, you should be able to handle it as follows:

var data= {"code": "0", "data": {"nowDate": "2018-09-03 14:25:57", "isCanUpdate": "0", "list": [{"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-17"}, {"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-18"}, {"times": [{"startTime": "09:00", "endTime": "21:30"], "day": "2018-09-19"}, {"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-20"}, {"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-21"}, {"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-22"}, {"times": [{"startTime": "09:00", "endTime": "21:30"}], "day": "2018-09-23"}]}, "info": "success"};

function validate (data) {

var nowDay=data.data.nowDate.substr(0,10);
var nowTime=parseInt(data.data.nowDate.substr(11).replace(/:/g,""));
for(var i=0;i<data.length;iPP){
    var item=data.data.list[i];
    if(item.day==nowDay){
        for(var j =0;j< item.times.length;jPP){
            var item2=item.times[i];
            if(nowTime>=parseInt(item2.startTime.replace(/:/g,""))*100&&nowTime<=parseInt(item2.endTime.replace(/:/g,""))*100){
                return true;
            }
        }
        //return false; //false
    }

}
return false;

}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e469ed-44be1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e469ed-44be1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?