判断时间点是否在时间区间内-创新互联
需求:使用echart将工作时间画出来;将24小时等份划分,每份6小时,然后将工作时间对应着这四个区间进行规划; type:区间1(00:00~06:00),区间2(06:00~12:00),区间3(12:00~18:00),区间4(18:00~24:00) 注意点:后台传过来的时间不能跨天(例如:2022-12-03 24:00:00不能改成2022-12-04 00:00:00),或者前端每次接收数据的时候进行转换! 数据格式: Array:{"beginTime":"2022-12-03 03:00:10","endTime":"2022-12-03 19:10:00"} resultDate:[] isDuringDate(beginTime,endTime,currentTime){ if(currentTime>beginTime&¤tTime=sectionDate1.getTime()&&endTime.getTime()<=sectionDate2.getTime()){ let map = {type:1,data:[beginTime,endTime]} resultData.push(map); return resultData; }else if(beginTime.getTime()>=sectionDate2.getTime()&&endTime.getTime()<=sectionDate3.getTime()){ let map = {type:2,data:[beginTime,endTime]} resultData.push(map) return resultData; }else if(beginTime.getTime()>=sectionDate3.getTime()&&endTime.getTime()<=sectionDate4.getTime()){ let map = {type:3,data:[beginTime,endTime]} resultData.push(map) return resultData; }else if(beginTime.getTime()>=sectionDate4.getTime()&&endTime.getTime()<=sectionDate5.getTime()){ let map = {type:4,data:[beginTime,endTime]} resultData.push(map) return resultData; }else{ if(this.isDuringDate(beginTime.getTime(),endTime.getTime(),sectionDate4.getTime())){ resultData.push({type:4,data:[sectionDate4,endTime]}) this.TimeRecursion({beginTime:beginTime,endTime:sectionDate4},resultData) }else if(this.isDuringDate(beginTime.getTime(),endTime.getTime(),sectionDate3.getTime())){ resultData.push({type:3,data:[sectionDate3,endTime]}) this.TimeRecursion({beginTime:beginTime,endTime:sectionDate3},resultData) }else if(this.isDuringDate(beginTime.getTime(),endTime.getTime(),sectionDate2.getTime())){ resultData.push({type:2,data:[sectionDate2,endTime]}) this.TimeRecursion({beginTime:beginTime,endTime:sectionDate2},resultData) } } },
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
创新互联主要从事网站制作、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务杂多,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792文章标题:判断时间点是否在时间区间内-创新互联
网站路径:http://azwzsj.com/article/dhhsio.html