Calendar
Try in Playground →ISO weeks, quarters, holidays, and calendar grids
Import
import { ... } from 'ts-time-utils/calendar'; Examples
Week & Quarter
Get week numbers, quarters, and calendar info
import { getWeekNumber, getQuarter, getDaysInMonth, getDaysInYear } from 'ts-time-utils/calendar';
const date = new Date('2025-09-14');
// ISO week number
console.log(getWeekNumber(date)); // 37
// Quarter
console.log(getQuarter(date)); // 3
// Days in month/year
console.log(getDaysInMonth(9, 2025)); // 30
console.log(getDaysInMonth(2, 2024)); // 29 (leap year)
console.log(getDaysInYear(2024)); // 366
console.log(getDaysInYear(2025)); // 365 US Holidays
Calculate US federal holidays
import { getEaster, getUSHolidays, getThanksgivingDay, getMemorialDay } from 'ts-time-utils/calendar';
// Easter (complex calculation!)
console.log(getEaster(2025));
// Get all US holidays for a year
const holidays = getUSHolidays(2025);
holidays.forEach(h => {
console.log(`${h.name}: ${h.date.toDateString()}`);
});
// Specific holidays
console.log('Thanksgiving 2025:', getThanksgivingDay(2025));
console.log('Memorial Day 2025:', getMemorialDay(2025));