Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel
subtractTime.ts1.25 kB
import { CacheTTL } from '../cache/timeCache'; import type { SubtractTimeParams, SubtractTimeResult } from '../types'; import { getConfig } from '../utils/config'; import { debug } from '../utils/debug'; import { resolveTimezone } from '../utils/timezoneUtils'; import { withCache } from '../utils/withCache'; import { addTime } from './addTime'; export function subtractTime(params: SubtractTimeParams): SubtractTimeResult { debug.timing('subtractTime called with params: %O', params); const { time, amount, unit, timezone } = params; const config = getConfig(); // Determine the effective timezone for cache key const effectiveTimezone = resolveTimezone(timezone, config.defaultTimezone); // Use withCache wrapper instead of manual cache management return withCache( `subtract_${time}_${amount}_${unit}_${effectiveTimezone}`, CacheTTL.CALCULATIONS, () => { debug.timing('Delegating to addTime with negated amount: %d', -amount); // Subtraction is just addition with negative amount const result = addTime({ time, amount: -amount, // Negate the amount unit, timezone, }); debug.timing('subtractTime returning: %O', result); return result; } ); }

Implementation Reference

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/pshempel/mcp-time-server-node'

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