@magmacomputing/tempo-plugin-holidays
The Regional Holidays Plugin provides bank holiday resolution, weekend observation shifts, SLA working hours calculations, and business day arithmetic for Tempo.
Key Features
- Zero-Latency Built-in Calendars: Instant synchronous holiday calculation for US, Australia, United Kingdom, Canada, Germany, France, Japan, and New Zealand.
t.geo.countryResolution Cascade: Automatically resolves national calendars via explicit option,tempo.geo.country,tempo.intl.region, or BCP-47tempo.locale.- Global Long-Tail Coverage (100+ Countries): Dynamic async preloading via
@magmacomputing/tempo-fnswith automatic 24-hour TTL caching in runtime storage. - SLA Working Hours Calculation:
t.holidays.workingHoursUntil(deadline)calculates business hours between dates, taking into account working hour windows, weekends, and regional holidays. - Cultural Weekend Awareness: Automatically respects cultural workweeks (e.g. Friday/Saturday weekend in Middle Eastern locales like
ar-SA).
Installation
bash
npm install @magmacomputing/tempo-plugin-holidaysQuickstart
Interactive Demo (@magmacomputing/tempo-plugin-holidays)
Open in Full REPL↗// 🏖️ Regional Public Holidays & SLA Business Days (@magmacomputing/tempo-plugin-holidays)
const { HolidaysPlugin } = await import('@magmacomputing/tempo-plugin-holidays');
Tempo.use(HolidaysPlugin);
// 1. Evaluate holiday by country or instance geo metadata
const christmas = new Tempo('2026-12-25', { geo: { country: 'US' } });
console.log('Is Christmas Day holiday in US?', christmas.holidays.isHoliday());
console.log('Holiday Name:', christmas.holidays.name);
console.log('Is Business Day?', christmas.holidays.isBusinessDay());
// 2. Next & previous business day arithmetic
const nextWorkDay = christmas.holidays.nextBusinessDay();
console.log('Next Business Day after Christmas:', nextWorkDay.format('{www}, {dd} {mon} {yyyy}'));
// 3. Add N working business days
const deadline = christmas.holidays.addBusinessDays(5);
console.log('5 Business Days later:', deadline.format('{www}, {dd} {mon} {yyyy}'));
// 4. SLA Working Hours calculation
const ticketOpened = new Tempo('2026-01-23 15:00:00', { geo: { country: 'AU' } });
const ticketResolved = new Tempo('2026-01-27 11:00:00', { geo: { country: 'AU' } });
const hours = ticketOpened.holidays.workingHoursUntil(ticketResolved);
console.log('SLA Working Hours (9am-5pm window):', hours, 'hours');
return `Christmas: ${christmas.holidays.name} (Next work day: ${nextWorkDay.format('{www}, {dd} {mon}')})`;typescript
import '@magmacomputing/tempo-plugin-holidays/install';
import { Tempo } from '@magmacomputing/tempo';
// Australia Day (Jan 26)
const t = new Tempo('2026-01-26', { geo: { country: 'AU' } });
console.log(t.holidays.isHoliday()); // true
console.log(t.holidays.name); // 'Australia Day'
console.log(t.holidays.isBusinessDay()); // false
// Advance to next valid business day past holidays & weekends
const nextWorkDay = t.holidays.nextBusinessDay();
console.log(nextWorkDay.format('{yyyy}-{mm}-{dd}')); // '2026-01-27'
// Calculate SLA working hours between dates
const start = new Tempo('2026-01-23 15:00:00', { geo: { country: 'AU' } }); // Friday 3pm
const deadline = new Tempo('2026-01-27 11:00:00', { geo: { country: 'AU' } }); // Tuesday 11am
console.log(start.holidays.workingHoursUntil(deadline)); // 4.0 hours (2h Fri + 0h Sat/Sun/Mon-Holiday + 2h Tue)Topic Guides
- Business Days & SLA Arithmetic - Working day calculations,
addBusinessDays,nextBusinessDay, andworkingHoursUntil. - Regional Calendars & Dynamic Preloading - Built-in country rules, state overlays, observation shifts, and async preloading for 100+ countries.
- Production Use Cases & Architectural Patterns - Multi-tenant SaaS SLA engines, T+2 trade settlement, payroll rolling conventions, and HR leave accounting.
License
This is a Community plugin. It is completely free and open-source for personal and commercial use under the MIT license. No license token is required.