Skip to main content
Glama
Date Math – Business Days, Holidays & Time Zones

Date Math – Business Days, Holidays & Time Zones

README.md
# Date Math

[![Listed on mcpservers.org](https://mcpservers.org/badge.svg)](https://mcpservers.org/servers/jowendelapena/date-math)
[![Date Math – Business Days, Holidays & Time Zones MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/JowenDelaPena/date-math/badges/score.svg)](https://glama.ai/mcp/servers/JowenDelaPena/date-math)
[![Date Math MCP on mcprush](https://mcprush.com/badge/jowendelapena-date-math-mcp/score.svg)](https://mcprush.com/to/jowendelapena-date-math-mcp?ref=badge)

[![Date Math – Business Days, Holidays & Time Zones MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/JowenDelaPena/date-math/badges/card.svg)](https://glama.ai/mcp/servers/JowenDelaPena/date-math)
[![Date Math MCP server](https://mcprush.com/badge/jowendelapena-date-math-mcp/card.svg)](https://mcprush.com/to/jowendelapena-date-math-mcp?ref=badge)

**Exact date and time math for AI agents, paid per call.** LLMs are unreliable at business days, DST, recurring schedules and holiday calendars. Date Math gives them deterministic answers over HTTP or MCP.

- **Price:** $0.001 per call in USDC on Base, via [x402](https://x402.org)
- **Free to try:** 25 free MCP tool calls per day, works in any MCP app (Claude Desktop, Cursor, ...)
- **Access:** no signup, no API keys
- **Base URL:** `https://date-math.datemath.workers.dev`
- **MCP endpoint:** `https://date-math.datemath.workers.dev/mcp` (Streamable HTTP)
- **Docs for agents:** [`/llms.txt`](https://date-math.datemath.workers.dev/llms.txt) · [`/openapi.json`](https://date-math.datemath.workers.dev/openapi.json)

## Tools

Each tool name links to its own page with a full description, an example and a live try-it box.

| HTTP (`POST`, JSON body) | MCP tool | What it does |
|---|---|---|
| `/v1/diff` | [`date_diff`](https://date-math.datemath.workers.dev/tools/date-diff) | Days, weeks, months and business days between two dates. Pass `country` to skip its public holidays, `workdays` for non Mon–Fri weeks. |
| `/v1/add` | [`date_add`](https://date-math.datemath.workers.dev/tools/date-add) | The date N days, weeks, months or business days before or after a date |
| `/v1/convert` | [`timezone_convert`](https://date-math.datemath.workers.dev/tools/timezone-convert) | Converts a time between IANA time zones (DST-aware) |
| `/v1/info` | [`date_info`](https://date-math.datemath.workers.dev/tools/date-info) | Weekday, ISO week, quarter, day of year, leap year |
| `/v1/holidays` | [`public_holidays`](https://date-math.datemath.workers.dev/tools/public-holidays) | Public holidays for 207 countries, 2000–2050 |
| `/v1/overlap` | [`working_hours_overlap`](https://date-math.datemath.workers.dev/tools/working-hours-overlap) | When working hours overlap across time zones (meeting slots) |
| `/v1/cron` | [`cron_schedule`](https://date-math.datemath.workers.dev/tools/cron-schedule) | Explains a cron expression and lists its next runs in any zone |
| `/v1/parse` | [`parse_date_text`](https://date-math.datemath.workers.dev/tools/parse-date-text) | "next Friday at 3pm" → an exact ISO datetime |
| `/v1/city` | [`city_time`](https://date-math.datemath.workers.dev/tools/city-time) | City name → time zone and local time (7,000+ cities) |
| `/v1/recurrence` | [`recurring_dates`](https://date-math.datemath.workers.dev/tools/recurring-dates) | Expands an iCal RRULE ("every 2nd Tuesday") into dates |
| `/v1/business_hours` | [`business_hours_deadline`](https://date-math.datemath.workers.dev/tools/business-hours-deadline) | SLA deadline N working hours from now, or working time elapsed |
| `/v1/business_day` | [`business_day`](https://date-math.datemath.workers.dev/tools/business-day) | Is a date a business day, and if not, why (weekend or which holiday); next/previous business day; the month's business days |
| `/v1/pay_dates` | [`pay_dates`](https://date-math.datemath.workers.dev/tools/pay-dates) | Payroll and billing dates (monthly, 15th and last, biweekly, weekly) moved off weekends and holidays |
| `/v1/stay` | [`stay_calculator`](https://date-math.datemath.workers.dev/tools/stay-calculator) | Schengen-style 90/180 stay limits: days used and left, overstay check, the longest stay from a planned entry date, the next date a full stay is possible |
| `/v1/timestamp` | [`timestamp_normalize`](https://date-math.datemath.workers.dev/tools/timestamp-normalize) | Converts up to 100 mixed timestamps (Unix s/ms/µs/ns, Excel serials, FILETIME, ISO 8601, RFC 2822, slash dates) to UTC and flags ambiguous ones like 03/04/2026 |
| `/v1/dst` | [`dst_check`](https://date-math.datemath.workers.dev/tools/dst-check) | A zone's daylight-saving clock changes for a year, and whether a local time is valid, skipped (spring-forward gap) or repeated (fall-back) |
| `/v1/sla` | [`sla_countdown`](https://date-math.datemath.workers.dev/tools/sla-countdown) | Live SLA clock for support tickets: business minutes elapsed and remaining, breached or not, deadline. Pauses outside working hours, on holidays and during manual pauses |
| `/v1/free_slots` | [`find_free_slots`](https://date-math.datemath.workers.dev/tools/find-free-slots) | Meeting slots when everyone is free: each person's working hours in their own zone (and holidays) minus their busy blocks |
| `/v1/subscription` | [`subscription_dates`](https://date-math.datemath.workers.dev/tools/subscription-dates) | Billing period, next renewal, cancel-by date for a notice period, trial start and day-based proration; month-end anchors stay at month end |
| `/v1/market` | [`market_calendar`](https://date-math.datemath.workers.dev/tools/market-calendar) | NYSE/Nasdaq, London and Tokyo: open now, session hours (early closes, lunch break), holidays, next open/close, settlement date (T+1/T+2) |
| `/v1/date_range` | [`date_range`](https://date-math.datemath.workers.dev/tools/date-range) | "last month", "this quarter", "YTD", "last 7 days", "2026-Q3" → exact start and end dates and times in a time zone, with an optional comparison period (previous period or same period last year) and fiscal years |
| `/v1/business_day_schedule` | [`business_day_schedule`](https://date-math.datemath.workers.dev/tools/business-day-schedule) | Holiday-aware job schedules cron can't express: "3rd business day at 09:00", "last business day", "every Monday or the next business day", any cron with a holiday rule. Next runs plus "does it run today?" |
| `/v1/time_buckets` | [`time_buckets`](https://date-math.datemath.workers.dev/tools/time-buckets) | Hour, day, week, month, quarter or year buckets for charts and time series, DST-aware (23- and 25-hour days), ISO or Sunday weeks, fiscal quarters |
| `GET /v1/now` | `current_time` | **Free:** the current date and time in up to 10 time zones. No payment, and it doesn't use the daily free calls |

## Use it in your app

The first 25 tool calls per day are free in all of these. No signup, no API key.

**Claude Code**

```bash
claude mcp add --transport http date-math https://date-math.datemath.workers.dev/mcp
```

**Claude Desktop / claude.ai:** Settings → Connectors → Add custom connector, and paste `https://date-math.datemath.workers.dev/mcp`. Or use the local package in `claude_desktop_config.json`:

```json
{ "mcpServers": { "date-math": { "command": "npx", "args": ["-y", "date-math-mcp"] } } }
```

**Cursor** (`~/.cursor/mcp.json`)

```json
{ "mcpServers": { "date-math": { "url": "https://date-math.datemath.workers.dev/mcp" } } }
```

**VS Code** (`.vscode/mcp.json`)

```json
{ "servers": { "date-math": { "type": "http", "url": "https://date-math.datemath.workers.dev/mcp" } } }
```

**Windsurf** (`~/.codeium/windsurf/mcp_config.json`)

```json
{ "mcpServers": { "date-math": { "serverUrl": "https://date-math.datemath.workers.dev/mcp" } } }
```

**Cline** (MCP Servers → Configure)

```json
{ "mcpServers": { "date-math": { "type": "streamableHttp", "url": "https://date-math.datemath.workers.dev/mcp" } } }
```

**Any app that only runs local commands:** `npx -y date-math-mcp` ([npm package](npm/README.md)). Set `DATE_MATH_PRIVATE_KEY` to a wallet with USDC on Base and it pays for calls beyond the free tier automatically.

**Vercel AI SDK**

```ts
import { createMCPClient } from "@ai-sdk/mcp";

const mcp = await createMCPClient({ transport: { type: "http", url: "https://date-math.datemath.workers.dev/mcp" } });
const tools = await mcp.tools(); // pass to generateText / streamText
```

**LangChain / LangGraph (Python)**

```python
from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({"date-math": {"transport": "streamable_http", "url": "https://date-math.datemath.workers.dev/mcp"}})
tools = await client.get_tools()
```

**OpenAI Agents SDK (Python)**

```python
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(name="date-math", params={"url": "https://date-math.datemath.workers.dev/mcp"}) as server:
    agent = Agent(name="Scheduler", instructions="Use date-math for any date or time calculation.", mcp_servers=[server])
    result = await Runner.run(agent, "What date is 10 business days after 2026-12-18 in Germany?")
    print(result.final_output)
```

**CrewAI**

```python
from crewai import Agent
from crewai_tools import MCPServerAdapter

params = {"url": "https://date-math.datemath.workers.dev/mcp", "transport": "streamable-http"}
with MCPServerAdapter(params) as tools:
    planner = Agent(role="Scheduler", goal="Get dates and deadlines exactly right", backstory="Never guesses dates.", tools=tools)
    # add the agent to a Task and Crew, then crew.kickoff() inside this block
```

**n8n:** add an **AI Agent** node, then attach an **MCP Client Tool** node to its Tool input. Set **Endpoint** to `https://date-math.datemath.workers.dev/mcp`, **Server Transport** to **HTTP Streamable**, and **Authentication** to **None**.

Business-day tools take `workdays` (weekday numbers, 0 = Sunday) for other workweeks, e.g. `[0,1,2,3,4]` for Sun–Thu or `[1,2,3,4,5,6]` for Mon–Sat.

Every response is a JSON object. Errors look like `{"error":{"code","message","example"}}`, where `example` is a valid request body for that tool. Full schemas and examples are in [`/openapi.json`](https://date-math.datemath.workers.dev/openapi.json).

## Examples

```bash
# Unpaid call → HTTP 402 with payment terms in the PAYMENT-REQUIRED header
curl -i -X POST https://date-math.datemath.workers.dev/v1/business_hours \
  -H "Content-Type: application/json" \
  -d '{"start":"2026-11-06T16:00","hours":2,"timezone":"Asia/Manila","country":"PH"}'
```

| Request body | Result |
|---|---|
| `/v1/business_hours` `{"start":"2026-11-06T16:00","hours":2,"timezone":"Asia/Manila"}` | `"deadline":"2026-11-09T10:00:00+08:00"` (Monday) |
| `/v1/add` `{"date":"2026-12-22","business_days":5,"country":"PH"}` | `"result":"2026-12-31"` (skips Christmas and Rizal Day) |
| `/v1/overlap` `{"timezones":["Asia/Manila","Europe/London"],"date":"2026-11-10","work_end":"18:00"}` | One window: `09:00–10:00Z` |
| `/v1/recurrence` `{"rrule":"FREQ=MONTHLY;BYDAY=2TU","start":"2026-01-01T10:00","timezone":"Asia/Manila","count":3}` | Jan 13, Feb 10, Mar 10 at 10:00 +08:00 |
| `/v1/business_day` `{"date":"2026-12-25","country":"PH"}` | Not a business day: `"holiday":"Christmas Day"`, next is `2026-12-28` |
| `/v1/pay_dates` `{"schedule":"semi_monthly","from":"2027-01-01","count":2}` | Jan 15, then Jan 31 (Sunday) moved to Fri Jan 29 |

## Paying from code

Any x402 client pays automatically. With the official TypeScript client:

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(privateKeyToAccount(process.env.KEY as `0x${string}`)) }],
});

const res = await pay("https://date-math.datemath.workers.dev/v1/city", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ cities: ["Cebu", "London"] }),
});
console.log(await res.json());
```

The wallet needs USDC on Base. No ETH is required, because the facilitator pays gas.

## Using it over MCP

- **Endpoint:** `https://date-math.datemath.workers.dev/mcp` (Streamable HTTP, stateless)
- **Listing tools** (`tools/list`) is free.
- **The first 25 tool calls per day are free** (per IP, reset at 00:00 UTC). Each free result carries `_meta["date-math/free_calls_remaining"]`.
- **After that, each tool call** costs $0.001 via x402 MCP. Payment travels in the tool call's `_meta`, and x402-aware clients handle it automatically:

```ts
import { createx402MCPClient } from "@x402/mcp";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const client = createx402MCPClient({
  name: "my-agent", version: "1.0.0",
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
  autoPayment: true,
});
await client.connect(new StreamableHTTPClientTransport(new URL("https://date-math.datemath.workers.dev/mcp")));
const r = await client.callTool("public_holidays", { country: "US", year: 2026 });
```

MCP clients without x402 support can use the free daily calls; after those, calls return "Payment required". A client that attaches a payment never uses up free calls.

The free tier is MCP only. Plain HTTP calls always need payment (an unpaid call returns 402), because x402 discovery services check for that.

## Run your own copy

The service is a single Cloudflare Worker and fits the free plan: every tool uses 0–6 ms of CPU per call.

```bash
cd worker
npm install
npm test                 # 189 tests, including end-to-end payments with the real x402 clients
npx wrangler login
npx wrangler deploy
```

Set your own wallet and price in [`worker/wrangler.toml`](worker/wrangler.toml):

| Setting | Meaning |
|---|---|
| `PAY_TO` | Your wallet address. Leave empty to make every endpoint free. |
| `PRICE` | Price per call, e.g. `$0.001` |
| `X402_NETWORK` | `eip155:8453` (Base) or `eip155:84532` (Base Sepolia, for testing) |
| `FACILITATOR_URL` | Defaults to PayAI: no key needed, and it pays gas |
| `FREE_CALLS_PER_DAY` | Free MCP tool calls per IP per day (default `25`, `0` turns it off). Counters live in the `FREE_QUOTA` Durable Object. |

Optional secrets (set with `npx wrangler secret put`):
- **`CDP_API_KEY_ID`, `CDP_API_KEY_SECRET`:** settle through Coinbase's facilitator first.
- **`POCKET_PREFIX`:** a private, unpaid path for trusted relays.

To check your deployment against x402scan's discovery rules, run `node tools/x402scan-audit.mjs https://your-worker.workers.dev`.
To check that it can actually take payments (HTTP and MCP, the way agents pay), run `API_URL=https://your-worker.workers.dev EXPECTED_PAY_TO=0xYourWallet node worker/scripts/payment-monitor.mjs`.

## How it's built

- **Stack:** [Hono](https://hono.dev) on Cloudflare Workers, plus [`@x402/hono`](https://www.npmjs.com/package/@x402/hono) and [`@x402/mcp`](https://www.npmjs.com/package/@x402/mcp).
- **Discovery:** OpenAPI with `x-payment-info`, `/.well-known/x402`, x402 Bazaar metadata on every 402, `llms.txt`, and an MCP [Server Card](https://modelcontextprotocol.io/seps/2127-mcp-server-cards) at `/mcp/server-card` listed in `/.well-known/ai-catalog.json`.
- **Precomputed data:** the holiday and city tables are built at build time (`worker/scripts/build-*.mjs`), so lookups are O(1) per request.
- **Time zones:** UTC offsets come from cached `Intl` formatters and a week-segment cache. They're tested against direct lookups for tricky zones (Morocco, Lord Howe, Chatham).
- **Cron:** a built-in engine (`worker/src/cron.ts`), checked against `cron-parser` on 400 random expressions.
- **Workers-specific shim:** x402's Bazaar route validator uses Ajv code generation (`new Function`), which Workers blocks. `wrangler.toml` aliases it to a no-op shim (`worker/src/shims/bazaar.ts`).

## Data and license

- **Code:** MIT, see [LICENSE](LICENSE). Third-party data notices are in [NOTICE](NOTICE).
- **Holiday data:** derived from [date-holidays](https://github.com/commenthol/date-holidays) (CC BY 3.0). Lunar or government-proclaimed dates are rule-based estimates.
- **City data:** derived from [city-timezones](https://github.com/kevinroberts/city-timezones) (MIT), based on Natural Earth (public domain).

Contact: see `info.contact` in [`/openapi.json`](https://date-math.datemath.workers.dev/openapi.json).

TDQS

A3.7/5.0

Scored across 24 tools

Disambiguation3/5

Most tools target distinct date/time computations, but several boundaries are fuzzy: business_hours_deadline vs sla_countdown both perform working-hour SLA math; working_hours_overlap vs find_free_slots both find meeting windows; and subscription_dates/pay_dates/recurring_dates/business_day_schedule all generate recurring billing or schedule dates. Detailed descriptions mitigate this, but real misselection risk remains.

Naming Consistency3/5

All names are snake_case and readable, but conventions are mixed: some are noun phrases (current_time, date_info, pay_dates), some are verb_noun (parse_date_text, find_free_slots), and others are compound domain labels (sla_countdown, dst_check). Consistent casing helps, but there is no single predictable action pattern.

Tool Count3/5

24 tools is at the heavy end of the rubric for a single server; although the date/time domain is broad and most tools cover distinct computations, the count raises selection cost and invites overlap. The set would benefit from grouping or consolidation.

Completeness5/5

The surface is very broad: current time, parsing, arithmetic, diffs, ranges/buckets, holidays, business-day rules, timezone conversion, DST, recurring schedules, cron, pay dates, SLA/deadline math and free-slot finding are all covered. No obvious lifecycle gap exists for date/time computation.

Maintenance

ActivityMaintained
ResponsivenessOutdated data