Skip to content

gaslamp


Class: CalendarArtisan

Advanced Google Calendar management with logging.

CalendarArtisan provides efficient calendar operations with comprehensive logging via AfterGlow. It helps retrieve calendar events and manage date calculations for calendar-based operations.

Remarks

  • Provides helper methods for event retrieval by date range
  • Includes month boundary calculations
  • Logs all operations for debugging and auditing
  • Thread-safe for use in Google Apps Script environment

Examples

Get events from current month:

TypeScript
const artisan = new CalendarArtisan({ name: "EventProcessor" });
const calendar = CalendarApp.getDefaultCalendar();
const events = artisan.getEventsInThisMonth(calendar);
console.log(`Found ${events.length} events this month`);

Get events in custom date range:

TypeScript
const artisan = new CalendarArtisan();
const calendar = CalendarApp.getDefaultCalendar();
const startDate = new Date("2026-03-01");
const endDate = new Date("2026-03-31");
const events = artisan.getEventsFromCalendar(calendar, startDate, endDate);

Since

0.48.1

Constructors

Constructor

new CalendarArtisan(options?): CalendarArtisan

Parameters

options?

CalendarArtisanOptions = {}

Returns

CalendarArtisan

Gaslets

getAfterGlow()

getAfterGlow(): AfterGlow

Get the internal AfterGlow logger instance for advanced usage.

Use this to access all logged operations or configure logging behavior.

Returns

AfterGlow

AfterGlow logger instance

Example

TypeScript
const artisan = new CalendarArtisan();
const logger = artisan.getAfterGlow();
const logs = logger.toMap();

getEventsFromCalendar()

getEventsFromCalendar(calendar, startDate, endDate): CalendarEvent[]

Retrieve events from a calendar within a date range.

Parameters

calendar

Calendar

Calendar object to query

startDate

Date

Start date (inclusive)

endDate

Date

End date (exclusive)

Returns

CalendarEvent[]

Array of CalendarEvent objects, or empty array if calendar is invalid

Example

TypeScript
const artisan = new CalendarArtisan();
const calendar = CalendarApp.getDefaultCalendar();
const start = new Date("2026-03-01");
const end = new Date("2026-03-31");
const events = artisan.getEventsFromCalendar(calendar, start, end);

getMonthBoundaries()

getMonthBoundaries(date): MonthBoundaries

Get month boundaries (first day of last, current, and next month).

Parameters

date

Date

Date within the target month

Returns

MonthBoundaries

MonthBoundaries object with lastMonth, thisMonth, nextMonth

Example

TypeScript
const artisan = new CalendarArtisan();
const boundaries = artisan.getMonthBoundaries(new Date());
console.log("This month starts at:", boundaries.thisMonth);

getEventsInLastMonth()

getEventsInLastMonth(calendar): CalendarEvent[]

Retrieve events from the previous month.

Parameters

calendar

Calendar

Calendar object to query

Returns

CalendarEvent[]

Array of CalendarEvent objects from last month

Example

TypeScript
const artisan = new CalendarArtisan();
const calendar = CalendarApp.getDefaultCalendar();
const lastMonthEvents = artisan.getEventsInLastMonth(calendar);

getEventsInThisMonth()

getEventsInThisMonth(calendar): CalendarEvent[]

Retrieve events from the current month.

Parameters

calendar

Calendar

Calendar object to query

Returns

CalendarEvent[]

Array of CalendarEvent objects from this month

Example

TypeScript
const artisan = new CalendarArtisan();
const calendar = CalendarApp.getDefaultCalendar();
const thisMonthEvents = artisan.getEventsInThisMonth(calendar);

Other

defaultName

readonly static defaultName: "CalendarArtisan" = "CalendarArtisan"