get_time_info
Retrieve current time details like timezone and day of week for accurate time-related queries across different locations.
Instructions
Get detailed time information including timezone, day of week, etc.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_time_info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | Timezone (optional, defaults to system timezone) | system |
Implementation Reference
- src/index.ts:157-208 (handler)Handler implementation for the 'get_time_info' tool. Extracts timezone from arguments (defaults to 'system'), computes detailed time information using Date object and Intl.DateTimeFormat for specific timezones, handles errors for invalid timezones, and returns a structured text response with JSON-formatted time info.
if (name === 'get_time_info') { const timezone = args?.timezone || 'system'; log('INFO', `Getting detailed time info - timezone: ${timezone}`); const now = new Date(); let timeInfo: any = { timestamp: now.getTime(), iso_string: now.toISOString(), local_time: now.toLocaleString(), day_of_week: now.toLocaleDateString('en-US', { weekday: 'long' }), date: now.toLocaleDateString('en-US'), year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), timezone_offset: now.getTimezoneOffset(), }; if (timezone !== 'system') { try { const tzFormatter = new Intl.DateTimeFormat('en-US', { timeZone: timezone as string, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName: 'short' }); timeInfo.timezone_time = tzFormatter.format(now); timeInfo.requested_timezone = timezone; } catch (error) { timeInfo.timezone_error = `Invalid timezone: ${timezone}`; } } const result = { content: [ { type: 'text', text: JSON.stringify(timeInfo, null, 2), }, ], }; log('INFO', 'Returning detailed time info'); return result; } - src/index.ts:83-97 (schema)Schema definition for the 'get_time_info' tool returned in tools/list response, including name, description, and inputSchema with optional 'timezone' string parameter.
{ name: 'get_time_info', description: 'Get detailed time information including timezone, day of week, etc.', inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'Timezone (optional, defaults to system timezone)', default: 'system' } }, additionalProperties: false, }, }