1
1
mirror of https://github.com/KenanZhu/AutoLibrary.git synced 2026-06-18 07:23:03 +08:00

fix(ALAutoScript*Dialog): 统一编排窗口生成的 Lua 函数名与 ASEngine 运行时一致

- date_add → dateadd, time_add → timeadd
- CURRENT_DATE() → datenow(), CURRENT_TIME() → timenow()
- 编辑窗口 Date/Time 字面量按钮模板同步更新为 date()/time() 格式

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 20:25:19 +08:00
parent eb8da498a2
commit f7167c13f4
4 changed files with 30 additions and 27 deletions
+13 -13
View File
@@ -90,7 +90,7 @@ DATE_OFFSET_OPTIONS = [
("", "days"),
("", "weeks"),
# NOTE: "月" and "年" use fixed day counts (30 / 365), not calendar months/years,
# because date_add() works with second-level offsets (n * 86400).
# because dateadd() works with second-level offsets (n * 86400).
("", "months"),
("", "years"),
]
@@ -423,7 +423,7 @@ def encodeValueStr(
Encode a raw widget value as a Lua expression.
Arithmetic expressions (A + B) are passed through for numeric types;
Date/Time arithmetic is translated to ``date_add()`` / ``time_add()`` calls.
Date/Time arithmetic is translated to ``dateadd()`` / ``timeadd()`` calls.
"""
if var_type in ("Date", "Time"):
@@ -464,24 +464,24 @@ def encodeDateOrTime(
right = m_arith.group(3).strip()
operand = right if sign == "+" else f"-{right}"
if left == "CURRENT_DATE":
return f"date_add(CURRENT_DATE(), {operand})"
return f"dateadd(datenow(), {operand})"
if left == "CURRENT_TIME":
return f"time_add(CURRENT_TIME(), {operand})"
return f"timeadd(timenow(), {operand})"
if var_type == "Date":
return f"date_add({left}, {operand})"
return f"dateadd({left}, {operand})"
if var_type == "Time":
return f"time_add({left}, {operand})"
return f"timeadd({left}, {operand})"
return f"{left} {sign} {right}"
if up == "CURRENT_DATE":
return "CURRENT_DATE()"
return "datenow()"
if up == "CURRENT_TIME":
return "CURRENT_TIME()"
return "timenow()"
_REL_MAP = {
"前天": "date_add(CURRENT_DATE(), -2)",
"昨天": "date_add(CURRENT_DATE(), -1)",
"今天": "CURRENT_DATE()",
"明天": "date_add(CURRENT_DATE(), 1)",
"后天": "date_add(CURRENT_DATE(), 2)",
"前天": "dateadd(datenow(), -2)",
"昨天": "dateadd(datenow(), -1)",
"今天": "datenow()",
"明天": "dateadd(datenow(), 1)",
"后天": "dateadd(datenow(), 2)",
}
if s in _REL_MAP:
return _REL_MAP[s]