get_current_date
Retrieve the current date with day-of-week information for any IANA timezone, optionally including time details, to ensure accurate timezone-aware date handling.
Instructions
Get the current date in a specific timezone with day of week information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | Yes | IANA timezone identifier (e.g., "America/New_York", "Europe/London") | |
| includeTime | No | Whether to include time information |
Implementation Reference
- src/index.ts:170-214 (handler)The handler implementation for the 'get_current_date' tool. It extracts parameters, validates the timezone, formats the current date with day of week information, optionally adds time details, and returns a JSON-formatted response.case 'get_current_date': { const { timezone, includeTime = false } = args as { timezone: string; includeTime?: boolean }; TimeService.validateTimezone(timezone); const now = new Date(); const dateInfo = { timezone, date: now.toLocaleDateString('en-US', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit' }), dayOfWeek: now.toLocaleDateString('en-US', { timeZone: timezone, weekday: 'long' }), fullDate: now.toLocaleDateString('en-US', { timeZone: timezone, weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }), }; if (includeTime) { const timeInfo = TimeService.getCurrentTime(timezone, 'full'); Object.assign(dateInfo, { time: timeInfo.datetime, fullDateTime: timeInfo.localizedFormat, isDST: timeInfo.isDST, utcOffset: timeInfo.utcOffset, }); } return { content: [ { type: 'text', text: JSON.stringify(dateInfo, null, 2), }, ], }; }
- src/index.ts:80-98 (registration)The tool registration object for 'get_current_date' in the tools array used by ListToolsRequestHandler, including description and input schema.{ name: 'get_current_date', description: 'Get the current date in a specific timezone with day of week information', inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'IANA timezone identifier (e.g., "America/New_York", "Europe/London")', }, includeTime: { type: 'boolean', description: 'Whether to include time information', default: false, }, }, required: ['timezone'], }, },
- src/index.ts:83-97 (schema)Input schema definition for the 'get_current_date' tool, defining parameters for timezone and optional includeTime.inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'IANA timezone identifier (e.g., "America/New_York", "Europe/London")', }, includeTime: { type: 'boolean', description: 'Whether to include time information', default: false, }, }, required: ['timezone'], },