stacks/calendar
publicClone
Push over the same URL. A password will not work: create a token under access tokens and use it in place of one.
- .config
- .github
- .vscode
- resources
- tests
- .editorconfig 147 B
- .env.example 157 B
- .gitattributes 89 B
- .gitignore 117 B
- .npmignore 276 B
- build.ts 351 B
- bun.lock 16.8 KB
- bunfig.toml 29 B
- CHANGELOG.md 26.8 KB
- CLAUDE.md 1.1 KB
- LICENSE.md 1.1 KB
- package.json 1.9 KB
- README.md 2.6 KB
- tsconfig.json 474 B
@stacksjs/calendar
Add to a Stacks project
The registry version installs project-shaped source files directly into your application:
buddy add calendarThis adds resources/components/CalendarLinks.stx and the calendar functions under resources/functions/calendar/. The stack contains STX and TypeScript source, so the installed files remain fully owned and editable by the application.
Dependency-free add-to-calendar links and RFC 5545 event generation for Google Calendar, Outlook, Office 365, Yahoo Calendar, Apple Calendar, and any application that imports ICS files.
Install
bun add @stacksjs/calendarCreate every calendar link
import { createCalendarLinks } from '@stacksjs/calendar'
const links = createCalendarLinks({
title: 'Stacks Launch',
start: '2026-07-21T17:00:00-07:00',
end: '2026-07-21T18:30:00-07:00',
description: 'Launch notes, demos, and questions',
location: 'Playa Vista, CA',
timezone: 'America/Los_Angeles',
url: 'https://stacksjs.org/launch',
})
links.google
links.outlook
links.office365
links.yahoo
links.ics
links.icsDataUrlProvider-specific functions are also exported:
import {
createIcs,
createIcsDataUrl,
googleCalendarUrl,
office365CalendarUrl,
outlookCalendarUrl,
yahooCalendarUrl,
} from '@stacksjs/calendar'All-day events
An omitted all-day end date means one day. Explicit all-day end dates are exclusive, matching Google Calendar and RFC 5545 semantics.
const conference = createCalendarLinks({
title: 'Stacks Conference',
start: '2026-09-14',
end: '2026-09-17',
allDay: true,
})This event covers September 14, 15, and 16.
ICS files
createIcs returns standards-compatible calendar text with CRLF line endings, escaped text, deterministic event UIDs, exclusive all-day end dates, and UTF-8-aware 75-octet line folding.
const ics = createIcs(event, {
productId: '-//Acme//Events//EN',
})createIcsDataUrl returns an encoded URL suitable for a download link. It uses percent encoding instead of btoa, so Unicode titles and descriptions remain valid.
Date behavior
- Timed events are emitted as UTC instants.
- A timed event without
endlasts 60 minutes by default. - Use
durationMinutesto select another default duration. - Invalid dates, empty titles, non-positive durations, and end times before start throw descriptive errors.
timezoneis forwarded to providers that support an explicit display timezone.
Development
bun install
bun test
bun run test:types
bun run lint
bun run buildLicense
MIT