Use Cases & Tutorials
Learn how to integrate Festivo API into real-world applications with these practical tutorials.
HR & Payroll Integration
Calculate Payroll Dates Excluding Holidays
Automatically determine payroll processing dates while avoiding public and city-specific holidays:
Smart Payroll Date Calculator
1import { FestivoClient } from '@festivo-io/festivo-sdk';23 async function getNextPayrollDate(country, cityCode, currentDate) {4 const client = new FestivoClient({ apiKey: process.env.FESTIVO_API_KEY || 'YOUR_API_KEY' });5 const year = new Date(currentDate).getFullYear();6 const { holidays } = await client.getHolidays(country, year, { regions: cityCode });7 const holidayDates = new Set(holidays.map(h => h.observed));89 let nextDate = new Date(currentDate);10 nextDate.setDate(nextDate.getDate() + 1);1112 while (true) {13 const dateStr = nextDate.toISOString().split('T')[0];14 const dayOfWeek = nextDate.getDay();15 if (dayOfWeek !== 0 && dayOfWeek !== 6 && !holidayDates.has(dateStr)) {16 return nextDate;17 }18 nextDate.setDate(nextDate.getDate() + 1);19 }20 }2122 const nextPayrollDate = await getNextPayrollDate('IT', 'IT-MILAN', '2026-12-06');23 console.log("Next payroll date: " + nextPayrollDate.toISOString().split('T')[0]);