jackwener/OpenCLI · error · Error
定时发布时间不能超过 14 天
Error message
定时发布时间不能超过 14 天
What it means
validateTiming also caps scheduled publish time at 14 days in the future (MAX_OFFSET = 14 * 86400). If unixSeconds exceeds now + MAX_OFFSET, it throws this Error meaning 'scheduled publish time cannot exceed 14 days', enforcing Douyin's maximum scheduling window.
Source
Thrown at clis/douyin/_shared/timing.js:10
const MIN_OFFSET = 7200; // 2 hours
const MAX_OFFSET = 14 * 86400; // 14 days
export function validateTiming(unixSeconds) {
if (!Number.isFinite(unixSeconds))
throw new Error(`无效的时间戳: ${unixSeconds}`);
const now = Math.floor(Date.now() / 1000);
if (unixSeconds < now + MIN_OFFSET)
throw new Error(`定时发布时间必须在至少 2 小时后`);
if (unixSeconds > now + MAX_OFFSET)
throw new Error(`定时发布时间不能超过 14 天`);
}
export function toUnixSeconds(input) {
if (typeof input === 'number')
return input;
if (/^\d+$/.test(input)) {
return Number(input);
}
const ms = new Date(input).getTime();
if (isNaN(ms))
throw new Error(`无效的时间格式: "${input}"`);
return Math.floor(ms / 1000);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Choose a time within the next 14 days and recompute the timestamp in seconds.
- Clamp or validate with unixSeconds <= Math.floor(Date.now()/1000) + 14*86400 before calling publish.
- Fix any milliseconds-vs-seconds unit mistakes (Date.now() vs Date.now()/1000).
- Split long-horizon campaigns into multiple scheduled posts within the 14-day window.
Example fix
// before: 30 days out — rejected const ts = Math.floor(Date.now() / 1000) + 30 * 86400; // after: clamp to just under the 14-day cap const cap = Math.floor(Date.now() / 1000) + 14 * 86400 - 3600; const ts = Math.min(desiredTs, cap); validateTiming(ts);
Defensive patterns
Strategy: validation
Validate before calling
const MAX_OFFSET = 14 * 86400;
const now = Math.floor(Date.now() / 1000);
if (ts > now + MAX_OFFSET) {
ts = now + MAX_OFFSET - 3600; // clamp to just inside the 14-day window
} Type guard
null
Try / catch
try {
validateTiming(ts);
} catch (e) {
if (e.message === '定时发布时间不能超过 14 天') {
console.error('pick a date within the next 14 days');
}
throw e;
} Prevention
- Keep schedules within a 14-day horizon; split longer campaigns
- Sanity-check timestamp magnitude to catch ms-vs-seconds bugs
- Clamp far-future defaults in scripts to the 14-day cap
- Show the allowed window (now+2h .. now+14d) to users entering dates
When it happens
Trigger: Timestamp more than 14 days ahead — e.g. scheduling next month's post, a milliseconds-vs-seconds mixup inflating the value, or a user entering a far-future date.
Common situations: Users trying to schedule a campaign weeks out; unit confusion where a ms timestamp makes the value appear enormous; timezone misconversion pushing the time days ahead; hardcoded far-future defaults in scripts.
Related errors
- 无效的时间戳: ${unixSeconds}
- 定时发布时间必须在至少 2 小时后
- 抖音上传提交缺少 SessionKey
- douyin delete aweme_id cannot be empty
- douyin delete aweme_id must be a numeric id
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/75794f2a9a60f3e9.
Report an issue: GitHub.