mqscript_datetime_adddays
Add specified days to a date-time variable in MQScript mobile automation, storing the result for scheduling or time-based operations.
Instructions
Add days to date time
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dateTimeVariable | Yes | DateTime variable name | |
| days | Yes | Number of days to add | |
| resultVariable | No | Variable name to store result | newDate |
Implementation Reference
- src/tools/plugin-commands.ts:242-253 (handler)The handler function that generates MQScript code for DateTime.AddDays operation and returns a response with the generated script.handler: async (args: { dateTimeVariable: string; days: number; resultVariable?: string }) => { const { dateTimeVariable, days, resultVariable = 'newDate' } = args; const script = `${resultVariable} = DateTime.AddDays(${dateTimeVariable}, ${days})`; return { content: [ { type: 'text', text: `Generated MQScript DateTime add days command:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds ${days} days to "${dateTimeVariable}".` } ] }; }
- src/tools/plugin-commands.ts:223-241 (schema)Defines the input schema for the tool, including required dateTimeVariable and days parameters, and optional resultVariable.inputSchema: { type: 'object' as const, properties: { dateTimeVariable: { type: 'string', description: 'DateTime variable name' }, days: { type: 'number', description: 'Number of days to add' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'newDate' } }, required: ['dateTimeVariable', 'days'] },
- src/index.ts:32-61 (registration)The ALL_TOOLS registry spreads DateTimeCommands (containing mqscript_datetime_adddays) for tool discovery and execution.const ALL_TOOLS = { // Basic Commands - 基础命令 ...TouchCommands, ...ControlCommands, ...ColorCommands, ...OtherCommands, // Standard Library - 标准库函数 ...MathFunctions, ...StringFunctions, ...TypeConversionFunctions, ...ArrayFunctions, // UI Commands - 界面命令 ...UIControlCommands, ...UIPropertyCommands, ...FloatingWindowCommands, // Extension Commands - 扩展命令 ...ElementCommands, ...DeviceCommands, ...PhoneCommands, ...SysCommands, // Plugin Commands - 插件命令 ...CJsonCommands, ...DateTimeCommands, ...FileCommands, ...TuringCommands, };
- src/index.ts:75-88 (registration)Registers the generic CallToolRequest handler that looks up the tool by name from ALL_TOOLS and invokes its handler.server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => { const { name, arguments: args } = request.params; const tool = Object.values(ALL_TOOLS).find(t => t.name === name); if (!tool) { throw new Error(`Unknown tool: ${name}`); } try { return await tool.handler(args as any || {}); } catch (error) { throw new Error(`Error executing tool ${name}: ${error instanceof Error ? error.message : String(error)}`); } });