jackwener/OpenCLI · error
时间格式错误: ${kwargs.time},请使用格式如 2025-04-01 14:00
Error message
时间格式错误: ${kwargs.time},请使用格式如 2025-04-01 14:00 What it means
`opencli boss invite` parses the --time argument with `new Date(kwargs.time).getTime()`. JavaScript's Date parsing is lenient but locale/region-dependent; if the value cannot be parsed (NaN), the command throws this Chinese 'invalid time format' error suggesting the 'YYYY-MM-DD HH:mm' shape. The parsed epoch ms is sent as interviewTime to BOSS's interview API.
Source
Thrown at clis/boss/invite.js:42
verbose(`Sending interview invitation to ${kwargs.uid}...`);
await navigateToChat(page);
const friend = await findFriendByUid(page, kwargs.uid, { checkGreetList: true });
if (!friend)
throw new Error('未找到该候选人');
const friendName = friend.name || '候选人';
// Get saved contact info
const contactData = await bossFetch(page, 'https://www.zhipin.com/wapi/zpinterview/boss/interview/contactInit', { allowNonZero: true, timeout: 10_000 });
const contactName = kwargs.contact || contactData.zpData?.contactName || '';
const contactPhone = contactData.zpData?.contactPhone || '';
const contactId = contactData.zpData?.contactId || '';
// Get saved address
const addressData = await bossFetch(page, 'https://www.zhipin.com/wapi/zpinterview/boss/interview/listAddress', { allowNonZero: true, timeout: 10_000 });
const savedAddress = addressData.zpData?.list?.[0] || {};
const addressText = kwargs.address || savedAddress.cityAddressText || savedAddress.addressText || '';
// Parse interview time
const interviewTime = new Date(kwargs.time).getTime();
if (isNaN(interviewTime)) {
throw new Error(`时间格式错误: ${kwargs.time},请使用格式如 2025-04-01 14:00`);
}
const params = new URLSearchParams({
uid: String(friend.uid),
securityId: friend.securityId || '',
encryptJobId: friend.encryptJobId || '',
interviewTime: String(interviewTime),
contactId,
contactName,
contactPhone,
address: addressText,
interviewType: '1',
});
await bossFetch(page, 'https://www.zhipin.com/wapi/zpinterview/boss/interview/invite.json', {
method: 'POST',
body: params.toString(),
});
return [{
status: '✅ 面试邀请已发送',View on GitHub (pinned to 49907e53dc)
Solutions
- Use the exact format '2025-04-01 14:00' (24-hour, zero-padded).
- Ensure --time is actually passed and non-empty.
- Quote the value in the shell so spaces survive: --time "2025-04-01 14:00".
- Convert locale formats (e.g. 04/01/2025 2:00 PM) to ISO-like form before invoking.
Example fix
// before opencli boss invite <uid> --time "明天下午2点" // after opencli boss invite <uid> --time "2025-04-01 14:00"
Defensive patterns
Strategy: validation
Validate before calling
function parseInterviewTime(s) {
if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(s)) {
throw new Error(`Bad time "${s}"; use 2025-04-01 14:00`);
}
const ms = new Date(s.replace(' ', 'T')).getTime();
if (Number.isNaN(ms)) throw new Error(`Unparseable time: ${s}`);
return ms;
} Type guard
function isValidTimeString(v) {
return typeof v === 'string' && !Number.isNaN(new Date(v.replace(' ', 'T')).getTime());
} Try / catch
try {
await run(['opencli', 'boss', 'invite', uid, '--time', '2025-04-01 14:00']);
} catch (e) {
if (e.message.includes('时间格式错误')) {
console.error('Format the time as YYYY-MM-DD HH:mm (24h, zero-padded).');
}
throw e;
} Prevention
- Always pass --time as 'YYYY-MM-DD HH:mm'.
- Quote the argument in shell to preserve the space.
- Never pass natural-language or locale-formatted dates.
- Validate with a regex before invoking the command.
When it happens
Trigger: Passing --time values like '04/01 2pm', '明天下午2点', '2025-4-1 14:0', or values with timezone suffixes that the runtime's V8 build fails to parse; also passing an empty or missing --time (new Date(undefined) → NaN).
Common situations: Users writing times in their locale format (US MM/DD/YYYY, Chinese natural language); omitting --time entirely; extra characters from shell quoting; non-Gregorian or relative date strings.
Related errors
- boss security-id contains unsupported characters
- 未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', '
- 无法解析定时时间: ${raw}
- <train-no> must not be empty
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b4d9a571bc237df1.
Report an issue: GitHub.