After Effects脚本 - 星期几

时间:2013-10-21 01:03:24

标签: extendscript after-effects

我正在尝试修改一个简单的小AE脚本,该脚本在源文本中显示星期几。我需要它显示明天和第二天 - 我可以通过使用+1和+2来做 - 但没有条件它会中断。我猜它是沿着的;如果d> 6,那么d = 0?不能完全正确的代码,一些帮助将非常感激!

d = new Date(Date(0));
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";

weekday[d.getDay()]

1 个答案:

答案 0 :(得分:0)

[编辑:非常抱歉,@ ndix,但以前的代码(已删除)完全有缺陷。否定不起作用。 使用以下代码]

timeDirectionIndex = 0;//initial for today or future
daysToAdd = -15;//you can make this zero or any positive or negative integer
d = new Date(Date(0));
var weekday=new Array(7);
if (daysToAdd < 0) {timeDirectionIndex = 1;}

//if time is reversed, uses second column

weekday[0]=["Sunday","Saturday"][timeDirectionIndex];
weekday[1]=["Monday","Friday"][timeDirectionIndex];
weekday[2]=["Tuesday","Thursday"][timeDirectionIndex];
weekday[3]=["Wednesday","Wednesday"][timeDirectionIndex];
weekday[4]=["Thursday","Tuesday"][timeDirectionIndex];
weekday[5]=["Friday","Monday"][timeDirectionIndex];
weekday[6]=["Saturday","Sunday"][timeDirectionIndex];

//Math.abs makes it always positive; we rely on order of array now
if (daysToAdd < 0) {
   wd=weekday[ ( Math.abs(daysToAdd) +  3 + ( 3 - d.getDay())  )%7 ];
} else {
   wd=weekday[ (Math.abs(daysToAdd) +  (  d.getDay()   ) )%7 ];
}

alert(wd);

[以前的代码没有工作]