gmt-arithmetic

Performs date arithmetic, duration math, and interval algebra using the Temporal-based GMT library.

6|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/northguild/gmt --skill gmt-arithmetic-northguild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gmt-arithmetic
Source: https://github.com/northguild/gmt/tree/main/packages/gmt/skills/gmt-arithmetic
Command: npx skills add https://github.com/northguild/gmt --skill gmt-arithmetic-northguild

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @northguild/gmt.

What problem does it solve? JavaScript date arithmetic is error-prone: month-end clamping, DST transitions, business-day rules, and interval overlap logic each have edge cases that silently produce wrong results. This Skill guides correct use of the @northguild/gmt library's arithmetic APIs so additions, diffs, spans, and interval operations behave predictably. ## Core Features & Use Cases - Point arithmetic and durations: Add or subtract { unit: number } objects, parse and normalize ISO 8601 duration strings, and bridge diffs to durations with diffDateAsDuration. - Interval algebra: Perform half-open [start, end) set operations over instants — overlap, intersect, merge, subtract, split, and sum — plus the older closed positional interval*Date family. - Business calendars: Compute business days with caller-supplied weekends and holidays via BusinessCalendar, rollDate, and mergeCalendars. - Use Case: A user asks how many business days fall between two dates in New York, skipping July 4th. The Skill directs the assistant to build a BusinessCalendar with weekend: [6, 7] and the holiday list, then call businessDaysBetween for the correct count. ## Quick Start Ask the assistant to calculate the difference between two dates or add a duration to a date using the @northguild/gmt library's arithmetic functions.

Frequently Asked Questions about gmt-arithmetic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add days or months to a date in JavaScript with Temporal?▼

Use GMT's addDate with a unit object, such as addDate("2024-03-15", { days: 5 }). Arithmetic clamps by default, so January 31 plus one month becomes February 29; pass { overflow: "reject" } to get an empty-string sentinel instead.

How do I check if two time intervals overlap in JavaScript?▼

Use intervalsOverlap from GMT's interval namespace, which treats intervals as half-open [start, end) over instant strings. Touching intervals do not overlap; the older positional intervalsOverlapUtc family is closed and includes shared endpoints, so do not mix the two models.

How do I calculate business days between two dates with holidays?▼

Build a BusinessCalendar with weekend as ISO weekday numbers and a holidays array, then call businessDaysBetween. The count is start-exclusive and end-inclusive, and GMT bundles no holiday table, so you supply holidays yourself.

Does GMT support ISO 8601 duration strings like P5D?▼

Yes, but only through the duration functions: parseDuration, addDuration, normalizeDuration, and diffDateAsDuration. The add* functions take a { unit: number } object, so passing "P5D" to addDate returns the empty-string sentinel.

Why does my elapsed time differ from wall-clock time across DST?▼

spanMs and spanNs measure actual elapsed time, while spanWallClock measures what the clock face showed. Across a DST transition a wall-clock day is 23, 24.5, or 25 real hours, so the two measures differ by the size of the shift.

What are the limits of GMT date arithmetic at extreme values?▼

GMT returns correct TC39 results across Temporal's full instant range from -271821-04-20 to +275760-09-13. spanNs and sumIntervals stay exact as bigints past Number.MAX_SAFE_INTEGER, and fractional or unsafe epoch inputs return the sentinel.