or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

component-parser.mdcomponents.mddesign-system.mdduration.mdevents.mdhelpers.mdindex.mdparsing.mdperiod-binary.mdproperties.mdrecurrence.mdtime.mdtimezone.mdvcard-time.md
tile.json

events.mddocs/

Event Management

High-level event representation with recurrence pattern support, exception handling, and occurrence calculation. The Event class provides a semantic layer over VEVENT components for easier manipulation of calendar events.

Capabilities

Event Class

High-level event representation built on top of ICAL.Component for VEVENT components.

/**
 * Event constructor
 * @param {ICAL.Component} component - VEVENT component (optional)
 * @param {Object} options - Event options (optional)
 * @param {boolean} options.strictExceptions - Verify exceptions by UUID
 * @param {Array} options.exceptions - Related exception events
 */
class ICAL.Event {
  constructor(component, options);
  
  // Properties
  component: ICAL.Component;      // Underlying VEVENT component
  exceptions: Object;             // Related exception events
  strictExceptions: boolean;      // UUID validation for exceptions
  THISANDFUTURE: string;         // Constant for range modifications
}

Event Properties

Convenient access to common event properties.

/**
 * Event summary/title
 * @type {string}
 */
get summary();
set summary(value);

/**
 * Event start date/time
 * @type {ICAL.Time}
 */
get startDate();
set startDate(value);

/**
 * Event end date/time
 * @type {ICAL.Time}
 */
get endDate();
set endDate(value);

/**
 * Event duration
 * @type {ICAL.Duration}
 */
get duration();
set duration(value);

/**
 * Event location
 * @type {string}
 */
get location();
set location(value);

/**
 * Event attendees
 * @type {ICAL.Property[]}
 */
get attendees();

/**
 * Event organizer
 * @type {ICAL.Property}
 */
get organizer();
set organizer(value);

/**
 * Event unique identifier
 * @type {string}
 */
get uid();
set uid(value);

/**
 * Event description
 * @type {string}
 */
get description();
set description(value);

/**
 * Event sequence number
 * @type {number}
 */
get sequence();
set sequence(value);

Usage Examples:

const ICAL = require('ical.js');

// Create new event
const event = new ICAL.Event();
event.summary = 'Team Meeting';
event.startDate = new ICAL.Time({
  year: 2023, month: 6, day: 15,
  hour: 10, minute: 0, second: 0
});
event.endDate = new ICAL.Time({
  year: 2023, month: 6, day: 15,
  hour: 11, minute: 0, second: 0
});
event.location = 'Conference Room A';
event.description = 'Weekly team sync meeting';

console.log(event.summary);     // 'Team Meeting'
console.log(event.duration);    // ICAL.Duration object (1 hour)

Recurrence Methods

Methods for handling recurring events and exceptions.

/**
 * Check if event has recurrence rules
 * @returns {boolean} True if event is recurring
 */
isRecurring();

/**
 * Check if event is an exception to a recurring series
 * @returns {boolean} True if event is a recurrence exception
 */
isRecurrenceException();

/**
 * Relate an exception event to this recurring event
 * @param {ICAL.Component|ICAL.Event} obj - Exception component or event
 * @throws {Error} If this event is itself an exception
 * @throws {Error} If UIDs don't match (when strictExceptions is true)
 */
relateException(obj);

/**
 * Check if exception modifies future occurrences (RANGE=THISANDFUTURE)
 * @returns {boolean} True if exception affects future occurrences
 */
modifiesFuture();

/**
 * Find range exception for given time
 * @param {ICAL.Time} time - Time to find exception for
 * @returns {ICAL.Event|null} Exception event or null
 */
findRangeException(time);

/**
 * Get occurrence details for specific time
 * @param {ICAL.Time} occurrence - Occurrence time
 * @returns {Object} Occurrence details
 */
getOccurrenceDetails(occurrence);

Recurrence Examples:

const ICAL = require('ical.js');

// Create recurring event
const recurringEvent = new ICAL.Event();
recurringEvent.summary = 'Daily Standup';
recurringEvent.startDate = ICAL.Time.fromString('20230615T090000Z');
recurringEvent.endDate = ICAL.Time.fromString('20230615T093000Z');

// Add recurrence rule
recurringEvent.component.addPropertyWithValue('rrule', 'FREQ=DAILY;COUNT=10');

console.log(recurringEvent.isRecurring()); // true

// Create exception event
const exceptionEvent = new ICAL.Event();
exceptionEvent.uid = recurringEvent.uid;
exceptionEvent.summary = 'Daily Standup - CANCELLED';
exceptionEvent.component.addPropertyWithValue('recurrence-id', '20230617T090000Z');

// Relate exception to main event
recurringEvent.relateException(exceptionEvent);

console.log(exceptionEvent.isRecurrenceException()); // true

Recurrence Information

/**
 * Get recurrence types used by this event
 * @returns {Object} Object with recurrence type information
 */
getRecurrenceTypes();

/**
 * Check if event occurs on specific day
 * @param {ICAL.Time} day - Day to check (time component ignored)
 * @returns {boolean} True if event occurs on given day
 */
isOnDay(day);

Event Creation and Serialization

/**
 * Convert event to string representation
 * @returns {string} String representation of event
 */
toString();

/**
 * Get event as iCalendar string
 * @returns {string} iCalendar formatted event
 */
toICALString();

Creation Examples:

const ICAL = require('ical.js');

// Create event from component
const veventComponent = new ICAL.Component('vevent');
veventComponent.addPropertyWithValue('uid', 'meeting@example.com');
veventComponent.addPropertyWithValue('summary', 'Project Review');
veventComponent.addPropertyWithValue('dtstart', '20230615T140000Z');
veventComponent.addPropertyWithValue('dtend', '20230615T160000Z');

const event = new ICAL.Event(veventComponent);

// Add attendees
const attendeeProperty = new ICAL.Property('attendee');
attendeeProperty.setValue('mailto:john@example.com');
attendeeProperty.setParameter('cn', 'John Doe');
attendeeProperty.setParameter('role', 'REQ-PARTICIPANT');
event.component.addProperty(attendeeProperty);

// Set organizer
const organizerProperty = new ICAL.Property('organizer');
organizerProperty.setValue('mailto:manager@example.com');
organizerProperty.setParameter('cn', 'Jane Manager');
event.component.addProperty(organizerProperty);

console.log(event.attendees.length); // 1
console.log(event.organizer.getFirstValue()); // 'mailto:manager@example.com'

All-Day Events

/**
 * Check if event is all-day (date-only start/end)
 * @returns {boolean} True if event is all-day
 */
isAllDay();

/**
 * Convert event to all-day event
 */
makeAllDay();

/**
 * Convert all-day event to timed event
 * @param {ICAL.Time} startTime - New start time
 * @param {ICAL.Time} endTime - New end time (optional)
 */
makeTimedEvent(startTime, endTime);

All-Day Examples:

const ICAL = require('ical.js');

// Create all-day event
const allDayEvent = new ICAL.Event();
allDayEvent.summary = 'Conference';
allDayEvent.startDate = new ICAL.Time({
  year: 2023, month: 6, day: 15,
  isDate: true  // This makes it a date-only value
});
allDayEvent.endDate = new ICAL.Time({
  year: 2023, month: 6, day: 17,
  isDate: true
});

console.log(allDayEvent.isAllDay()); // true

// Convert to timed event
const startTime = new ICAL.Time({
  year: 2023, month: 6, day: 15,
  hour: 9, minute: 0
});
const endTime = new ICAL.Time({
  year: 2023, month: 6, day: 15,
  hour: 17, minute: 0
});

allDayEvent.makeTimedEvent(startTime, endTime);
console.log(allDayEvent.isAllDay()); // false

Event Status and Classification

/**
 * Event status
 * @type {string} TENTATIVE, CONFIRMED, or CANCELLED
 */
get status();
set status(value);

/**
 * Event classification
 * @type {string} PUBLIC, PRIVATE, or CONFIDENTIAL
 */
get classification();
set classification(value);

/**
 * Event transparency (busy/free time)
 * @type {string} OPAQUE or TRANSPARENT
 */
get transparency();
set transparency(value);

/**
 * Event priority (0-9, 0=undefined, 1=highest, 9=lowest)
 * @type {number}
 */
get priority();
set priority(value);

Alarm Support

/**
 * Get all alarms for this event
 * @returns {ICAL.Component[]} Array of VALARM components
 */
getAlarms();

/**
 * Add alarm to event
 * @param {ICAL.Component} alarm - VALARM component
 */
addAlarm(alarm);

/**
 * Remove alarm from event
 * @param {ICAL.Component} alarm - VALARM component to remove
 */
removeAlarm(alarm);

Alarm Examples:

const ICAL = require('ical.js');

const event = new ICAL.Event();
event.summary = 'Important Meeting';
event.startDate = ICAL.Time.fromString('20230615T140000Z');

// Create display alarm 15 minutes before
const alarm = new ICAL.Component('valarm');
alarm.addPropertyWithValue('action', 'DISPLAY');
alarm.addPropertyWithValue('description', 'Meeting reminder');
alarm.addPropertyWithValue('trigger', '-PT15M'); // 15 minutes before

event.addAlarm(alarm);

console.log(event.getAlarms().length); // 1