对于javascript来说相对较新,大多数自我学习都是通过反复试验和互联网搜索完成的。代码有问题,我可以使用一些专家指导。
我需要显示所有更改,其中包含计划更改开始日期,该更改发生在我们的更改星期内,该更改开始于星期五的00:00:01,结束于下一个星期四的23:59:59。该报告将显示该时间段内计划的开始日期的所有更改。
我能够找到以下脚本,其中包含针对我的特定要求进行了稍微修改的脚本。在报表中调用脚本时,即使有符合我条件的数据,我也没有收到任何结果。
我相信我的问题出在数组或循环上,但无法解决。
我只相信该问题所在的脚本的一部分,但是如果有帮助,可以提供完整的代码。
//部分代码
var ChangesPlannedCustom = Class.create();
ChangesPlannedCustom.prototype = {
initialize: function() {
},
testChangeWeek:function(){
//Gets all current dates within current week and push into 'result'
var current = new Date();
var gdt1 = new GlideDateTime(current);
var dateToday = gdt1.getLocalDate();
var sunday = new Date(current.setDate(current.getDate() - current.getDay()));
var b = gdt1.getLocalDate();
var result = [b];
while (sunday.setDate(sunday.getDate() + 1) && sunday.getDay() !== 0) {
var curr = new Date(sunday);
var gdt = new GlideDateTime(curr);
var c = gdt.getLocalDate();
result.push(c);
}
//Assigns dates with numbers. Days contain respective dates.
//SundayN = 0, MondayN = 1, TuesdayN = 2, WednesdayN = 3, ThursdayN = 4, FridayN = 5, SaturdayN = 6
var sunday1, monday, tuesday, wednesday, thursday, friday, saturday; //sunday1 because sunday is already used above
var sundayN, mondayN, tuesdayN, wednesdayN, thursdayN, fridayN, saturdayN;
var today = dateToday;
var i = [];
for (i = 0; i < result.length; i++) {
switch (i) {
case 0:
sunday1 = result[i];
sundayN = i;
break;
case 1:
monday = result[i];
mondayN = i;
break;
case 2:
tuesday = result[i];
tuesday = i;
break;
case 3:
wednesday = result[i];
wednesday = i;
break;
case 4:
thursday = result[i];
thursday = i;
break;
case 5:
friday = result[i];
friday = i;
break;
case 6:
saturday = result[i];
saturday = i;
break;
default: statement(s);
break;
}
}
var todayN = '';
var q;
for (q = 0; q < result.length; q++) {
if (result[q].toString() == today.toString()) {
todayN = q;
}
}
//代码继续-未显示
我希望收到一份变更编号列表,这些变更编号的计划开始日期在我的特定日期范围内。目前,在执行报告中的代码时,没有收到任何结果。
感谢提供的任何帮助。