1

我在这里已经脱离了我的元素,我在黑暗中绊倒了每个脚趾至少两次。

我有一个从周日到周六运行的时间表表格,看起来有点像:

    "Button to fill in dates for the week"
    Sun "Date field" In LunchOut LunchIn Out Total
    Mon "Date field" In LunchOut LunchIn Out Total
    .
    .
    .
    Sat

当我按下按钮时,我希望它填写该周的正确日期,无论我在一周中的什么时候按下它。我拼凑了一些我在网上找到的 javascript 代码片段,但我没有足够的框架来理解我在做什么......但是,奇怪的是,我觉得我在正确的轨道上,去图.

这是我到目前为止所得到的

    function fillDates(){
        var startDay = 0; //0=sunday, 1=monday etc.
    //    var d = now.getDay(); //get the current day
        var d = ("m/d/yy",new Date());
        var weekStart = new Date(now.valueOf() - (d<=0 ? 7-startDay:d-startDay*86400000); //rewind to start day
        var weekd1 = new Date(weekStart.valueOf() + 1*86400000); //add 1 days to get last day
        var weekd2 = new Date(weekStart.valueOf() + 2*86400000); //add 2 days to get last day
        var weekd3 = new Date(weekStart.valueOf() + 3*86400000); //add 3 days to get last day
        var weekd4 = new Date(weekStart.valueOf() + 4*86400000); //add 4 days to get last day
        var weekd5 = new Date(weekStart.valueOf() + 5*86400000); //add 5 days to get last day
        var weekEnd = new Date(weekStart.valueOf() + 6*86400000); //add 6 days to get last day
        this.getField("Sunday").value = weekStart

    //    var sun = this.getField("Sunday");
    //    sun.value = util.printd("m/d/yy",weekStart());
    //    var fld = this.getField("Monday");
    //    fld.value = util.printd("m/d/yy",new Date());
    }
    fillDates();

Acrobat 首先在“var d” now.getDay() 声明中抱怨“now”,所以我将其更改为下一行(不知道这是否可行),然后它抱怨 weekStart now.valueOf() 和我不知道那指的是什么,没有例子,早上没有时间。我的印象是 acrobat 的 javascript 可能只有一部分可用的 javascript 内容,并且“现在”不包括在内……但这是一个完全的猜测。

指导?

4

1 回答 1

0

我想到了...

var d = util.printd("dddd",new Date());
switch (d){
case "Sunday":
     d = 0;
     break;
case "Monday":
     d = 1;
     break;
case "Tuesday":
     d = 2;
     break;
case "Wednesday":
     d = 3;
     break;
case "Thursday":
     d = 4;
     break;
case "Friday":
     d = 5;
     break;
case "Saturday":
     d = 6;
     break;
}

var rightNow = new Date();
var msRightNow = rightNow.getTime();
var startDay = 0;
var rightNow = new Date();
var dMS = rightNow.getTime();
var weekStart = new Date(dMS - (d<=0 ? 7-startDay:d-startDay)*86400000);
var msWeekStart = weekStart.getTime();
var weekd2 = new Date(msWeekStart + 1*86400000); //add 1 days to get last day
var weekd3 = new Date(msWeekStart + 2*86400000); //add 2 days to get last day
var weekd4 = new Date(msWeekStart + 3*86400000); //add 3 days to get last day
var weekd5 = new Date(msWeekStart + 4*86400000); //add 4 days to get last day
var weekd6 = new Date(msWeekStart + 5*86400000); //add 5 days to get last day
var weekd7 = new Date(msWeekStart + 6*86400000); //add 6 days to get last day
var sunday = this.getField("Sunday");
sunday.value = util.printd("m/d/yy",weekStart);
var monday = this.getField("Monday");
monday.value = util.printd("m/d/yy",weekd2);
var tuesday = this.getField("Tuesday");
tuesday.value = util.printd("m/d/yy",weekd3);
var wednesday = this.getField("Wednesday");
wednesday.value = util.printd("m/d/yy",weekd4);
var thursday = this.getField("Thursday");
thursday.value = util.printd("m/d/yy",weekd5);
var friday = this.getField("Friday");
friday.value = util.printd("m/d/yy",weekd6);
var saturday = this.getField("Saturday");
saturday.value = util.printd("m/d/yy",weekd7);
于 2013-03-26T12:41:35.623 回答