Skip to main content
Glama

convertTimezone

Convert date/time strings between timezones using ISO 8601 and IANA timezone identifiers. Specify source, target timezones, and output format for accurate conversions.

Instructions

Convert date/time between timezones using Luxon

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesDate/time string to convert (ISO 8601 format)
formatNoOutput format (full, date, time, iso)full
fromTZYesSource timezone (IANA timezone identifier)
toTZYesTarget timezone (IANA timezone identifier)

Implementation Reference

  • The core handler function that performs the timezone conversion using Luxon, including parsing, validation, conversion, formatting based on input format, and returning JSON result.
    handler: async ({ 
      date, 
      fromTZ, 
      toTZ, 
      format = 'full' 
    }: { 
      date: string; 
      fromTZ: string; 
      toTZ: string; 
      format?: 'full' | 'date' | 'time' | 'iso' 
    }) => {
      try {
        const dt = DateTime.fromISO(date, { zone: fromTZ });
        
        if (!dt.isValid) {
          throw new Error(`Invalid date format or timezone: ${dt.invalidReason}`);
        }
    
        const converted = dt.setZone(toTZ);
        
        if (!converted.isValid) {
          throw new Error(`Invalid target timezone: ${converted.invalidReason}`);
        }
    
        let formattedOriginal: string;
        let formattedConverted: string;
    
        switch (format) {
          case 'full':
            formattedOriginal = dt.toLocaleString(DateTime.DATETIME_FULL);
            formattedConverted = converted.toLocaleString(DateTime.DATETIME_FULL);
            break;
          case 'date':
            formattedOriginal = dt.toLocaleString(DateTime.DATE_FULL);
            formattedConverted = converted.toLocaleString(DateTime.DATE_FULL);
            break;
          case 'time':
            formattedOriginal = dt.toLocaleString(DateTime.TIME_WITH_SECONDS);
            formattedConverted = converted.toLocaleString(DateTime.TIME_WITH_SECONDS);
            break;
          case 'iso':
            formattedOriginal = dt.toISO();
            formattedConverted = converted.toISO();
            break;
          default:
            throw new Error(`Unsupported format: ${format}`);
        }
    
        const result: TimezoneConversionResult = {
          originalDate: formattedOriginal,
          convertedDate: formattedConverted,
          fromTimezone: fromTZ,
          toTimezone: toTZ
        };
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }]
        };
      } catch (error) {
        throw new Error(`Timezone conversion failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Input schema defining the parameters for the convertTimezone tool: date (ISO string), fromTZ, toTZ (IANA IDs), optional format.
    inputSchema: {
      type: 'object',
      properties: {
        date: {
          type: 'string',
          description: 'Date/time string to convert (ISO 8601 format)'
        },
        fromTZ: {
          type: 'string',
          description: 'Source timezone (IANA timezone identifier)'
        },
        toTZ: {
          type: 'string',
          description: 'Target timezone (IANA timezone identifier)'
        },
        format: {
          type: 'string',
          description: 'Output format (full, date, time, iso)',
          enum: ['full', 'date', 'time', 'iso'],
          default: 'full'
        }
      },
      required: ['date', 'fromTZ', 'toTZ']
    },
  • src/index.ts:27-33 (registration)
    Registration of dateTimeTools (which includes convertTimezone) by spreading into the central allTools object used for MCP tool listing and execution.
    const allTools: ToolKit = {
      ...encodingTools,
      ...geoTools,
      ...generatorTools,
      ...dateTimeTools,
      ...securityTools
    };
  • TypeScript interface defining the structure of the timezone conversion result object.
    export interface TimezoneConversionResult {
      originalDate: string;
      convertedDate: string;
      fromTimezone: string;
      toTimezone: string;
    }
  • src/index.ts:7-7 (registration)
    Import of dateTimeTools containing the convertTimezone tool definition.
    import { dateTimeTools } from './tools/datetime.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions Luxon as the underlying library but doesn't disclose error handling, validation behavior, performance characteristics, or what happens with invalid timezone identifiers. This leaves significant gaps in understanding how the tool behaves in edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that directly states the tool's purpose. There's zero waste or redundancy, and it's front-loaded with the essential information. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (converted date/time string? object?), doesn't mention error conditions, and provides no examples. The 100% schema coverage helps, but the description should do more to compensate for missing annotations and output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain parameter relationships, provide examples, or clarify usage patterns. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting date/time between timezones using Luxon. It specifies the verb (convert) and resource (date/time between timezones), but doesn't explicitly differentiate from sibling tools like listTimezones, which serves a different but related function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like listTimezones for timezone lookup, or clarify scenarios where this conversion is needed versus other date/time manipulation tools that might exist elsewhere.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-helper-tools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server