ReviewOS

stacks/calendar

public
Clone

Push over the same URL. A password will not work: create a token under access tokens and use it in place of one.

main
· 4 branches · 45 commits

Mirrored from stacksjs/calendar · syncing is switched off

README.md

@stacksjs/calendar

Add to a Stacks project

The registry version installs project-shaped source files directly into your application:

buddy add calendar

This 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/calendar
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.icsDataUrl

Provider-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 end lasts 60 minutes by default.
  • Use durationMinutes to select another default duration.
  • Invalid dates, empty titles, non-positive durations, and end times before start throw descriptive errors.
  • timezone is forwarded to providers that support an explicit display timezone.

Development

bun install
bun test
bun run test:types
bun run lint
bun run build

License

MIT