ProvenPin Install

Temporal polyfill PlainDate and Duration: working versions (tested 2026-10-15)

Work with calendar dates using @js-temporal/polyfill Temporal.PlainDate and Duration, covering add, until and timezone-free math offline.

passed2 passed · 0 failed2026-10-15 16:05 UTC
Status
passed
Last passed
2026-10-15 16:05 UTC
Tests
2 / 2
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
@js-temporal/polyfill@0.5.1@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("temporal-polyfill-dates") (install), or see them on GitHub.

package.json
{
  "name": "temporal-polyfill-dates",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {"@js-temporal/polyfill":"0.5.1"},
  "devDependencies": {"@types/node":"26.6.5","tsx":"4.23.15"}
}
src/dates.ts
import { Temporal } from "@js-temporal/polyfill";

export function addBusinessDays(isoDate: string, days: number) {
  let date = Temporal.PlainDate.from(isoDate);
  let remaining = days;
  const step = days >= 0 ? 1 : -1;
  while (remaining !== 0) {
    date = date.add({ days: step });
    const dow = date.dayOfWeek;
    if (dow !== 6 && dow !== 7) remaining -= step;
  }
  return date.toString();
}

export function daysBetween(a: string, b: string) {
  const start = Temporal.PlainDate.from(a);
  const end = Temporal.PlainDate.from(b);
  return start.until(end, { largestUnit: "day" }).days;
}

export function monthEnd(isoDate: string) {
  return Temporal.PlainDate.from(isoDate).with({ day: 1 }).add({ months: 1 }).subtract({ days: 1 }).toString();
}
test/dates.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { addBusinessDays, daysBetween, monthEnd } from "../src/dates.ts";

test("skips weekends when adding business days", () => {
  // 2026-10-15 is Thursday
  assert.equal(addBusinessDays("2026-10-15", 1), "2026-10-16");
  assert.equal(addBusinessDays("2026-10-15", 3), "2026-10-20");
});

test("daysBetween and monthEnd", () => {
  assert.equal(daysBetween("2026-10-01", "2026-10-15"), 14);
  assert.equal(monthEnd("2026-02-10"), "2026-02-28");
});

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

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.