Skip to content

Install

  • The core functions, which every industry uses.

Latest release: v1.24.0

Terminal window
pnpm add @northguild/gmt

GMT runs in any browser or runtime that parses ECMAScript 2022 and whose Intl.DateTimeFormat accepts IANA time zones. On Node, its engines field asks for >=22.16.0. It ships its own Temporal, so a built-in Temporal is not needed. Temporal in every engine shows the weekly test runs on each engine.

ISO 8601 strings go in and come out. There is no Date object to create first.

import { addDate, addZoned, diffDate, formatDate } from "@northguild/gmt";
addDate("2024-01-31", { months: 1 }); // "2024-02-29"
diffDate("2024-01-01", "2024-03-15", "days"); // 74
formatDate("2024-03-15", "en-US", { dateStyle: "long" }); // "March 15, 2024"
// A day is a calendar day, even across Berlin's clock change that night
addZoned("2024-03-30T12:00:00+01:00[Europe/Berlin]", { days: 1 }); // "2024-03-31T12:00:00+02:00[Europe/Berlin]"
// Bad input returns a value, never an exception
addDate("2024-02-30", { days: 1 }); // ""
diffDate("not a date", "2024-03-15", "days"); // null

Check for "", null, false or [] where you would otherwise catch an error. The Core Rules list every fallback.

Every public function, type and regex is a flat named export of the package root, and Temporal, Intl and toTemporalInstant are re-exported beside them, from temporal-polyfill in 1.24.0 and later, and from @js-temporal/polyfill up to 1.23.1. There are no namespace objects to import — a namespace is a subpath:

// Everything is available from the package root
import { addDate, formatRelativeZoned, getNow, Temporal } from "@northguild/gmt";
// A namespace subpath, if you only want one family of helpers
import { addZoned, getZonedNow } from "@northguild/gmt/zoned";
import { addUtc, getUtcNow } from "@northguild/gmt/utc";
import { addUnix, getUnixNow } from "@northguild/gmt/unix";
// A module subpath narrows further, to one namespace's module
import { addDateTime, diffDate } from "@northguild/gmt/plain/calculate";
// Types come from the `types` subpath
import type { BusinessCalendar } from "@northguild/gmt/types";

Every namespace subpath except types also re-exports Temporal, Intl and toTemporalInstant, so import { Temporal, addZoned } from "@northguild/gmt/zoned" needs no second import.

Module subpaths (@northguild/gmt/<namespace>/<module>) exist for every namespace except regex and types, which you import whole. The reference lists each export under its namespace and module.

There are fourteen namespace subpaths:

SubpathWhat it covers
calendarISO week and ordinal dates, quarter and fiscal periods, zone-aware bucketing, business calendars with holiday sets and roll conventions, and operating hours with open-time SLA arithmetic
durationISO 8601 duration string parsing, validation, arithmetic and totals, and unit objects such as { minutes: 15 } written as a duration string or totalled
instantThe instant-plus-offset pair, and explicit resolution of zoneless local wall times
intermodalFree time, demurrage and detention counted in the terminal’s local days, with the charged dates behind every count; the invoice, dispute and resolution deadline chain, with every window a caller parameter; bill of lading dates on the local calendar of the place each event happened; an end-to-end multimodal ETA; and the UN/EDIFACT, X12 and GS1 EPCIS timestamps freight exchanges
intervalHalf-open [start, end) interval algebra over instants: overlap, intersect, clamp, merge, subtract, split and sum
plainTimezone-free helpers
precisionNanosecond (bigint) instants, their JSON bridge, storage truncation, and foreign epoch bridges
regexLow-level regex building blocks
spanElapsed and wall-clock durations between two timestamps, as raw numbers
transportTransit legs as exact elapsed time, arrivals rendered where they land, dwell measured in local calendar days, crossings read in the zone that administers them, multi-leg schedules with missed connections flagged, cut-offs counted back from an anchor event, punctuality against a stated tolerance, and the next departure a connection can make
typesThe shared option and unit types
unixUnix epoch (seconds or milliseconds) helpers
utcUTC instant helpers
zonedTimezone-aware helpers

Every @northguild/* package ships TanStack Intent skill files inside the npm tarball — versioned, task-routed guidance that you can hand to a coding agent so it works with the right GMT API for each job. A skill carries the core rules and the common pitfalls, and points the agent to this site (https://northguild.dev/gmt/llms.txt, plus the .md twin of any page) and to the JSDoc in the installed package for signatures and examples.

Discover and load them with the Intent CLI:

Terminal window
# 1. One-time setup — writes skill-loading guidance into AGENTS.md
npx @tanstack/intent@latest install
# 2. Discover all available skills from installed packages
npx @tanstack/intent@latest list
# 3. Load a specific skill into an agent session
npx @tanstack/intent@latest load @northguild/gmt#gmt-basics

The linter packages (@northguild/gmt-eslint, @northguild/gmt-oxlint, @northguild/gmt-biome) use the same mechanism. Intent auto-detects your package manager and generates the correct runner (npx / pnpm dlx / yarn dlx / bunx).

To restrict which skills an agent may load, add an intent.skills allowlist to your package.json:

{
"intent": {
"skills": ["@northguild/gmt#gmt-basics", "@northguild/gmt#gmt-timezone"]
}
}
PackageSlugTask area
@northguild/gmtgmt-basicsCurrent date/time, parse, format, relative time, compare, validate
@northguild/gmtgmt-arithmeticAdd/subtract, diff, durations, interval range math
@northguild/gmtgmt-timezoneTimezone-aware arithmetic, formatting, DST disambiguation
@northguild/gmtgmt-integrationCache keys, router/query params, foreign epoch bridges, TAI and leap seconds, lint package selection

The industry skills are layers on top of those four, not part of Core:

PackageSlugTask area
@northguild/gmtgmt-gnssGNSS time scales, broadcast and RINEX week numbers, rollover eras
@northguild/gmtgmt-financeFIX UTCTimestamp values: precision from the digit count, picoseconds, leap seconds
@northguild/gmtgmt-transportTransit legs, connections, cut-offs, punctuality, departures
@northguild/gmtgmt-intermodalFree time, demurrage, billing deadlines, bill of lading dates, EDI and EPCIS timestamps
@northguild/gmtgmt-workforceHours-of-work rules over a duty log, with the caller’s own limits
@northguild/gmtgmt-healthcareHL7 v2 date-times, with the sender’s local time kept apart from UTC
Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.