Javascript:After Effects 和 Date() 函数 returns 未定义

Javascript: After Effects and Date() function returns undefined

情况是这样的。

  1. 我的团队制作了每周三播放的公告视频。介绍始终相同,除了日期(文本层为“[Long Month] xx, 20xx”)。
  2. 我正在尝试编写一些简单的自动化程序,使日期 始终 成为正确的星期三,而不管导出日期如何(星期三之前强制日期提前,星期三之后强制日期提前到下一个星期三)。

我的代码可以在浏览器中运行,但不能在 After Effects 中运行。在 AE 中它 returns 为 undefined. 帮助! (运行 后效 14.2.1.34)

var today, day, date, month

today = new Date(Date(0));
day = today.getDay();
date = today.getDate();
month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];


function printDate() {
  return month[today.getMonth()] + " " + date + ", " + today.getFullYear();
}


function forceWednesday() {
  if (day === 3) {
    printDate();
  } else if (day < 3) {
    var x = day;
    x = 3 - day;
    return month[today.getMonth()] + " " + (date + x) + ", " + today.getFullYear();
  } else if (day > 3) {
    var dayDiff, dateDiff, nextWed, newDate, wed
    dayDiff = day - 3;
    dateDiff = date - dayDiff;
    nextWed = today.setDate(dateDiff + 7);
    newDate = new Date(nextWed);
    wed = newDate.getDate();
    return month[newDate.getMonth()] + " " + wed + ", " + newDate.getFullYear();
  }
}

forceWednesday();

已修复。 See it live on Github.