Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
getCalendarMonthView
✓ import { getCalendarMonthView } from 'calendar-utils';
✗ const { getCalendarMonthView } = require('calendar-utils');
calendar-utils is primarily designed for ESM usage. While CommonJS might work via transpilation, direct require is not the idiomatic way.
getCalendarWeekView
✓ import { getCalendarWeekView } from 'calendar-utils';
✗ import getCalendarWeekView from 'calendar-utils';
All primary view generation functions are named exports; there is no default export.
getCalendarDayView
✓ import { getCalendarDayView, getWeekViewHeader } from 'calendar-utils';
✗ import * as calendarUtils from 'calendar-utils';
It's best practice to import only the specific functions you need to optimize bundle size.
This quickstart demonstrates how to generate a calendar month view using `getCalendarMonthView` with `date-fns` for date manipulation.
import { getCalendarMonthView } from 'calendar-utils';
import { startOfMonth, endOfMonth, eachDayOfInterval, format, addMonths } from 'date-fns';
interface CalendarDay {
date: Date;
isToday: boolean;
isWeekend: boolean;
events: string[];
}
const currentDate = new Date();
const monthStart = startOfMonth(currentDate);
const monthEnd = endOfMonth(currentDate);
const calendarMonthView = getCalendarMonthView({
date: currentDate,
events: [], // Your events array, e.g., [{ start: new Date(), end: new Date(), title: 'Meeting' }]
weekStartsOn: 0, // Sunday
excluded: [], // e.g., [6] for Saturday
viewStart: monthStart,
viewEnd: monthEnd,
hourSegments: 2, // Not directly used by month view, but part of config
dayStartHour: 0,
dayEndHour: 23,
weekendDays: [0, 6]
});
console.log(`Month View for ${format(currentDate, 'MMMM yyyy')}:`);
calendarMonthView.days.forEach(day => {
console.log(` ${format(day.date, 'yyyy-MM-dd')} (isCurrentMonth: ${day.inMonth}): ${day.events.length} events`);
});
// Example of getting a day outside the current month (for navigation)
const nextMonth = addMonths(currentDate, 1);
const nextMonthView = getCalendarMonthView({
date: nextMonth,
events: [],
weekStartsOn: 0,
excluded: [],
viewStart: startOfMonth(nextMonth),
viewEnd: endOfMonth(nextMonth),
hourSegments: 2,
dayStartHour: 0,
dayEndHour: 23,
weekendDays: [0, 6]
});
Errors
Common errors & fixes
Error: Cannot find module 'date-fns' (or 'luxon' or 'moment')
A required peer dependency for date manipulation (e.g., date-fns) is not installed in your project.
fixInstall the missing date library: `npm install date-fns` or `npm install luxon` or `npm install moment`.
TypeError: getCalendarMonthView is not a function
This usually means you are attempting to use a CommonJS `require` statement on a library primarily designed for ESM, or using incorrect named/default import syntax.
fixEnsure you are using ESM `import { getCalendarMonthView } from 'calendar-utils';` and your project supports ESM. Argument of type 'string' is not assignable to parameter of type 'Date'.
The `calendar-utils` functions expect native JavaScript `Date` objects (or objects compatible with the chosen date library's `Date` type) for date parameters, not strings.
fixEnsure all date inputs (e.g., `date`, `viewStart`, `viewEnd` arguments) are `new Date()` objects, or parsed by your chosen date library (e.g., `parseISO('2023-01-01')` from `date-fns`). Audit
Dependencies
date-fnsrequiredRequired for date manipulation if chosen as the adapter. One of the peer dependencies must be installed and configured.
luxonrequiredRequired for date manipulation if chosen as the adapter. One of the peer dependencies must be installed and configured.
momentrequiredRequired for date manipulation if chosen as the adapter. One of the peer dependencies must be installed and configured.