Date Math

io.github.JowenDelaPena由 GitHub 帳號 JowenDelaPena 發布v1.5.0更新於 Nov 7, 2026

Date/time math for agents: business days, holidays, time zones, cron, RRULE. 25 free calls/day.

已驗證Streamable HTTP可網頁執行效率與工作流開發者工具

概覽

AI 產生的概覽

為助理提供確定性的日期時間運算:工作日、假日、時區、cron 與重複排程,每天 25 次免費呼叫。

可以做什麼
  • 計算兩個日期之間的差距,以及依天、週、月或工作日增減日期,可排除國家法定假日
  • 在 IANA 時區之間換算時間,並查詢數千個城市的當地時間與時區
  • 列出國定假日,判斷某天是否為工作日,並給出上一個或下一個工作日
  • 找出跨時區的工作時間重疊時段,並依工作小時計算 SLA 截止時間
  • 解釋 cron 運算式,並把 iCalendar 重複規則展開成具體日期
  • 解析自然語言日期,並產生發薪或帳單日期
適用情境
適合助理需要處理截止日期、工作日、日光節約時間、假日行事曆或重複排程的情境,這些正是語言模型容易出錯的地方。也適用於跨時區排會、SLA 與薪資計算,以及理解使用者輸入的日期。
執行需求
可使用遠端 Streamable HTTP 端點,或以 npx 執行本機 npm 套件(需要 Node.js)。不需註冊或 API 金鑰。使用遠端端點需要網路連線。超過每天 25 次免費呼叫後,付款需要 DATE_MATH_PRIVATE_KEY(持有 Base 上 USDC 的錢包),並可用 DATE_MATH_MAX_PRICE 限制單次花費。
安裝前請注意
每天超過 25 次後每次呼叫收費 0.001 美元(Base 上的 USDC),支援 x402 的用戶端會自動付款;免費額度依 IP 計算且僅限 MCP,一般 HTTP 呼叫一律需要付費。設定 DATE_MATH_PRIVATE_KEY 等於把可花錢的錢包交給此服務,建議使用專用且餘額很低的金鑰。農曆或政府臨時公布的假日為依規則估算。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Date Math,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.JowenDelaPena%2Fdate-math/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

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

README

Date Math

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
  • 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 · /openapi.json

Tools

HTTP (POST, JSON body)MCP toolWhat it does
/v1/diffdate_diffDays, weeks, months and business days between two dates. Pass country to skip its public holidays, workdays for non Mon–Fri weeks.
/v1/adddate_addThe date N days, weeks, months or business days before or after a date
/v1/converttimezone_convertConverts a time between IANA time zones (DST-aware)
/v1/infodate_infoWeekday, ISO week, quarter, day of year, leap year
/v1/holidayspublic_holidaysPublic holidays for 207 countries, 2000–2050
/v1/overlapworking_hours_overlapWhen working hours overlap across time zones (meeting slots)
/v1/croncron_scheduleExplains a cron expression and lists its next runs in any zone
/v1/parseparse_date_text"next Friday at 3pm" → an exact ISO datetime
/v1/citycity_timeCity name → time zone and local time (7,000+ cities)
/v1/recurrencerecurring_datesExpands an iCal RRULE ("every 2nd Tuesday") into dates
/v1/business_hoursbusiness_hours_deadlineSLA deadline N working hours from now, or working time elapsed
/v1/business_daybusiness_dayIs a date a business day, and if not, why (weekend or which holiday); next/previous business day; the month's business days
/v1/pay_datespay_datesPayroll and billing dates (monthly, 15th and last, biweekly, weekly) moved off weekends and holidays

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). 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()

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.

Examples

bash
# Unpaid call → HTTP 402 with payment terms in the PAYMENT-REQUIRED headercurl -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 bodyResult
/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 workernpm installnpm test                 # 189 tests, including end-to-end payments with the real x402 clientsnpx wrangler loginnpx wrangler deploy

Set your own wallet and price in worker/wrangler.toml:

SettingMeaning
PAY_TOYour wallet address. Leave empty to make every endpoint free.
PRICEPrice per call, e.g. $0.001
X402_NETWORKeip155:8453 (Base) or eip155:84532 (Base Sepolia, for testing)
FACILITATOR_URLDefaults to PayAI: no key needed, and it pays gas
FREE_CALLS_PER_DAYFree 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 on Cloudflare Workers, plus @x402/hono and @x402/mcp.
  • Discovery: OpenAPI with x-payment-info, /.well-known/x402, x402 Bazaar metadata on every 402, llms.txt, and an MCP Server Card 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. Third-party data notices are in NOTICE.
  • Holiday data: derived from date-holidays (CC BY 3.0). Lunar or government-proclaimed dates are rule-based estimates.
  • City data: derived from city-timezones (MIT), based on Natural Earth (public domain).

Contact: see info.contact in /openapi.json.

來源:README.md,提交 a456cf6

工具

13

date_diff

Date difference

How many days, weeks, months or business days between two dates or datetimes: calendar (Y/M/D), totals, and business days (weekdays in [from, to) minus holidays; pass country to exclude its public holidays). Use for age, tenure, countdowns, notice periods and working days until a deadline. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數to必填from必填countryholidaysworkdays

date_add

Add to a date

Add or subtract years/months/weeks/days/business days/hours/minutes/seconds from a date. Month-end clamping; business days skip weekends, given holidays, and the public holidays of an optional country. Use for due dates, deadlines, delivery estimates, expiry and "N working days from today". First 25 calls per day are free, then $0.001 per call (x402).

輸入參數date必填dayshoursweeksyearsmonthscountryminutessecondsholidaysworkdaysbusiness_days

timezone_convert

Convert time zones

Convert a time between time zones (IANA names like Asia/Manila, America/New_York), DST-aware. Use for "what time is 3pm Manila in New York", scheduling across zones and UTC offsets. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數datetimeto_timezone必填from_timezone

date_info

Date facts

Calendar facts for a date: day of the week, ISO week number, quarter, day of year, leap year, weekend. Use for "what day is", week numbers and fiscal quarters. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數date必填

public_holidays

Public holidays

List public holidays (bank holidays, national holidays) for a country and year: 207 countries, 2000–2050. Use for holiday calendars, office closures and checking if a date is a holiday. Lunar or government-proclaimed dates are rule-based estimates. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數yearcountry必填

working_hours_overlap

Working-hours overlap

Find when working hours overlap across time zones: the best meeting times for a distributed or remote team. Per-participant hours optional; skips weekends by default; up to 14 days. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數datedayswork_endtimezoneswork_startparticipantsskip_weekends

cron_schedule

Cron schedule

Explain a cron expression in plain English and list its next run times in any time zone. Use to check or debug crontab and scheduled-job schedules. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數fromcounttimezoneexpression必填

parse_date_text

Parse natural-language dates

Parse natural-language dates and relative times like "next Friday at 3pm", "in 2 weeks", "tomorrow morning" or "Dec 25 to Jan 2" into exact ISO datetimes, relative to a reference time and time zone. Use before acting on any date a user typed. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數text必填timezonereferenceforward_date

city_time

City time zone and local time

Find the time zone and current local time in up to 10 cities by name ("Cebu", "São Paulo", "Springfield" + country). 7,000+ cities. Use for "what time is it in" questions and to get the IANA zone the other tools need. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數atcitycitiescountry

recurring_dates

Expand recurring events (RRULE)

Expand a recurring event or iCalendar RRULE ("every 2nd Tuesday", "Mon/Wed until June") into concrete dates and times in a time zone, DST-aware, with optional excluded dates. Use for repeating meetings, calendar invites and schedules. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數countrrule必填start必填excludetimezone

business_hours_deadline

Business-hours deadline / SLA

SLA math in working hours: the deadline N business hours after a start time, or business time elapsed between two times. Use for support-ticket SLAs, response-time targets and office-hours deadlines. Custom hours and workdays, holidays, country public holidays, DST-aware. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數endhoursstartcountryminutesholidaystimezone必填work_endworkdayswork_start

business_day

Business-day check

Is a date a business day? If not, why (weekend, or which public holiday). Also the next and previous business day, and the month's business-day count, first and last business day. Use for office-open checks, shipping cut-offs, settlement dates. Country holidays, custom holidays and custom workweeks (e.g. Sun–Thu, Mon–Sat). First 25 calls per day are free, then $0.001 per call (x402).

輸入參數date必填countryholidaysworkdays

pay_dates

Payroll and billing dates

Upcoming pay or billing dates for monthly, semi-monthly (e.g. 15th and last day), biweekly or weekly schedules, moved off weekends and public holidays (to the previous, next or nearest business day). Use for payroll calendars, invoice due dates and recurring billing. First 25 calls per day are free, then $0.001 per call (x402).

輸入參數daysfrom必填countadjustanchorcountryholidaysschedule必填workdays

版本歷史

1
  1. v1.5.0最新Nov 7, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分