dayjs UTC, timezone and duration plugins: working versions (tested 2026-10-15)
Work with dayjs plugins for UTC conversion, IANA time zones, durations and relative time, formatting Anchorage and UTC timestamps without network calls.
passed2 passed · 0 failed2026-10-15 15:57 UTC- Status
- passed
- Last passed
- 2026-10-15 15:57 UTC
- Tests
- 2 / 2
- Language
- TypeScript
- Runtime
- node v22.23.3
pinned versions3
dayjs@1.11.23@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false npm test
test environment
node v22.23.3 linux 6.17.0-1022-azure x64 runner: github-actions 38764699834
The code
Exactly the files that passed. Your agent can pull them with get_recipe("dayjs-utc-timezone-plugins") (install), or see them on GitHub.
package.json
{
"name": "dayjs-utc-timezone-plugins",
"private": true,
"type": "module",
"scripts": {
"test": "node --import tsx --test test/*.test.ts"
},
"dependencies": {
"dayjs": "1.11.23"
},
"devDependencies": {
"@types/node": "26.6.5",
"tsx": "4.23.15"
}
}
src/time.ts
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import timezone from "dayjs/plugin/timezone.js";
import duration from "dayjs/plugin/duration.js";
import relativeTime from "dayjs/plugin/relativeTime.js";
import customParseFormat from "dayjs/plugin/customParseFormat.js";
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(duration);
dayjs.extend(relativeTime);
dayjs.extend(customParseFormat);
export function parseLocal(input: string, tz: string) {
return dayjs.tz(input, "YYYY-MM-DD HH:mm", tz);
}
export function toUtcIso(input: string, tz: string) {
return parseLocal(input, tz).utc().toISOString();
}
export function shiftBusinessHours(startIso: string, hours: number) {
return dayjs.utc(startIso).add(dayjs.duration({ hours })).toISOString();
}
export function describeFrom(fromIso: string, toIso: string) {
return dayjs.utc(fromIso).from(dayjs.utc(toIso), true);
}
test/time.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { describeFrom, parseLocal, shiftBusinessHours, toUtcIso } from "../src/time.ts";
test("converts Anchorage local time to UTC", () => {
// 2026-01-15 12:00 AKST = UTC-9
const iso = toUtcIso("2026-01-15 12:00", "America/Anchorage");
assert.equal(iso, "2026-01-15T21:00:00.000Z");
assert.equal(parseLocal("2026-01-15 12:00", "America/Anchorage").format("Z"), "-09:00");
});
test("duration add and relative time", () => {
assert.equal(shiftBusinessHours("2026-01-15T21:00:00.000Z", 3), "2026-01-16T00:00:00.000Z");
assert.equal(describeFrom("2026-01-15T21:00:00.000Z", "2026-01-15T23:00:00.000Z"), "2 hours");
});
Connect to ProvenPin
Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.
terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp
~/.cursor/mcp.json
{ "mcpServers": { "provenpin": { "url": "https://mcp.provenpin.com/mcp" } } }.vscode/mcp.json
{ "servers": { "provenpin": { "type": "http", "url": "https://mcp.provenpin.com/mcp" } } }~/.codeium/windsurf/mcp_config.json
{ "mcpServers": { "provenpin": { "serverUrl": "https://mcp.provenpin.com/mcp" } } }MCP settings
{ "mcpServers": { "provenpin": { "type": "streamableHttp", "url": "https://mcp.provenpin.com/mcp" } } }Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.