Skip to content

Business Calendars and Roll Conventions

  • The core functions, which every industry uses.

A business day answers “is this a working day here”. The answer depends on the weekend and on the holidays of one place, so every function in this family takes a BusinessCalendar that states both. This guide covers the calendar, the day counting and stepping functions, the roll conventions, and how to merge calendars when a date has to work in two places at once. For the first look at weekdays and business-day arithmetic, see Comparisons and Plain Arithmetic.

A BusinessCalendar is { weekend: number[], holidays: string[], timeZone: string }.

  • The weekend is explicit. It is a list of ISO weekday numbers, because Saturday and Sunday are not universal. Much of the Middle East is Friday and Saturday, and some markets keep a one-day weekend.
  • Holidays are yours to supply. The library bundles no holiday table, because holiday data belongs to a jurisdiction and changes every year, sometimes with days of notice. buildBusinessCalendar builds a calendar from the rules you supply (see Build a calendar from rules).
  • timeZone records which locality the calendar describes. The business-day functions take and return local dates and never read it. If you hold an instant, reduce it to a local date with floorToZone first.

isBusinessDay, addBusinessDays and subtractBusinessDays all take a calendar as an optional trailing argument. The rest of the family requires one, because there is no default weekend to fall back on: businessDaysBetween, nextBusinessDay, previousBusinessDay, rollDate and mergeCalendars.

businessDaysBetween counts with the start exclusive and the end inclusive. nextBusinessDay and previousBusinessDay are strict: they never return the date you gave them.

import {
businessDaysBetween,
nextBusinessDay,
previousBusinessDay,
rollDate,
mergeCalendars,
isValidBusinessCalendar,
isBusinessDay,
} from "@northguild/gmt";
const london = {
weekend: [6, 7],
holidays: ["2024-05-31", "2024-12-25"],
timeZone: "Europe/London",
};
businessDaysBetween("2024-12-23", "2024-12-27", london);
// 3 — start exclusive, end inclusive, and 25 December is a holiday
nextBusinessDay("2024-12-24", london);
// "2024-12-26" — strictly after, skipping the holiday
previousBusinessDay("2024-12-26", london);
// "2024-12-24"

rollDate moves a date onto a working day by an explicit convention. The six conventions are following, modifiedFollowing, preceding, modifiedPreceding, endOfMonth and none.

following and preceding mean on-or-after and on-or-before, so they leave a working day alone. nextBusinessDay and previousBusinessDay are the strict neighbours.

rollDate("2024-05-31", "following", london);
// "2024-06-03" — forward past the weekend
rollDate("2024-05-31", "modifiedFollowing", london);
// "2024-05-30" — backward instead, because forward leaves May
rollDate("2024-03-15", "endOfMonth", london);
// "2024-03-29" — March's last working day; March ends on a Sunday
rollDate("2024-06-01", "none", london);
// "2024-06-01" — unadjusted, Saturday or not

mergeCalendars composes jurisdictions. Weekend rules and holidays union, so a date survives only if it is a working day in every input. That is the two-currency intersection that FX settlement needs, and the two-port one that an intermodal move needs.

The merged timeZone is the first calendar’s, because the merged set spans localities that may disagree. An empty list has no calendar to return, so mergeCalendars([]) is null.

const tokyo = { weekend: [6, 7], holidays: ["2024-07-04"], timeZone: "Asia/Tokyo" };
const both = mergeCalendars([london, tokyo]);
// { weekend: [6, 7], holidays: ["2024-05-31", "2024-07-04", "2024-12-25"], timeZone: "Europe/London" }
// timeZone is the first calendar's; the merged set spans localities that may disagree
isBusinessDay("2024-07-04", both);
// false — a holiday of either calendar closes the merged one
mergeCalendars([]);
// null

A holiday list is a set of dates, but a holiday is a rule: “1 January”, “the second Monday of October”, “two days before Easter”. buildBusinessCalendar takes a zone, a weekend, a list of rules and the years to expand them over, and returns a BusinessCalendar. It returns null when any part is invalid. A HolidayRule has one of five kinds:

  • fixed: a month and a day in the ISO calendar.
  • calendarFixed: a month code and a day in another calendar, such as M01 in the Hebrew calendar. The day must be one the month has in some year. A year whose month is shorter has no date.
  • nthWeekday: the first to fifth or last weekday of a month.
  • easterRelative: a number of days before or after Easter, by the Gregorian or the Julian method.
  • dates: a list of dates you give, for a day that no rule produces.

A fixed or calendarFixed rule can also carry an observed policy: for each weekday it names where the holiday moves, to a given weekday before or after, or to the next working day. Observance has no default. A rule with no policy closes its own date, and the library never fills one in for you.

A "nextWorkingDay" shift walks past every closed day: the weekend, every holiday that does not walk, and the walks of the rules above it. Two holidays on a Saturday and a Sunday, each moved to the next working day, close Monday and then Tuesday, because the second one finds Monday already closed. The order of the rules decides only which holiday takes which day; the days that close are the same in any order.

import { buildBusinessCalendar } from "@northguild/gmt";
const nextWorking = { 6: "nextWorkingDay", 7: "nextWorkingDay" } as const;
buildBusinessCalendar({
timeZone: "UTC",
weekend: [6, 7],
years: { from: 2021, to: 2021 },
rules: [
{ name: "a", kind: "fixed", month: 12, day: 25, observed: nextWorking },
{ name: "b", kind: "fixed", month: 12, day: 26, observed: nextWorking },
],
})?.holidays;
// ["2021-12-27", "2021-12-28"] — the second shift passes the first, in either order

A moved holiday closes one day. The calendar closes the observed date, not the date the holiday started on. To close both days, list the rule twice, once with no policy:

buildBusinessCalendar({
timeZone: "UTC",
weekend: [6, 7],
years: { from: 2021, to: 2021 },
rules: [
{ name: "a", kind: "fixed", month: 12, day: 25, observed: nextWorking },
{ name: "a", kind: "fixed", month: 12, day: 25 },
],
})?.holidays;
// ["2021-12-25", "2021-12-27"] — the moved day and the day itself

Three tools draw the same calls on a calendar:

isValidBusinessCalendar and isValidRollConvention narrow a candidate. When a function returns its sentinel, they let you tell a misconfigured calendar or contract term apart from bad date input.

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.