HSCalendarEvent
TypeAn event from a calendar, as returned by hs.eventkit.events() and its relatives.
Each property is read from the underlying calendar event when you access it, so fetching many events is cheap even when you only look at a few of their properties. An event is a snapshot: if it changes in Calendar after you fetched it, fetch it again to see the change.
Don't create these yourself; they come from hs.eventkit.
- Example:
hs.eventkit.eventsToday().forEach(e => {
console.log(e.startDate.toLocaleTimeString() + " " + e.title + (e.location ? " @ " + e.location : ""))
})
Properties
id
The event's identifier on this Mac.
Every occurrence of a repeating event has the same id, so use it together with
occurrenceDate (or startDate) to tell occurrences apart.
externalID
The identifier the calendar server gives the event, which is the same on every device but isn't guaranteed to be unique.
occurrenceDate
The original start of this occurrence of a repeating event, which stays the same if the occurrence is moved.
timeZone
The event's time zone (e.g. "Europe/London"), or null for a floating event that
follows the Mac's time zone.
isActive
Whether the event is happening now: from its start up to (but not including) its end, or for an all-day event, at any time on the days it covers.
This is worked out each time you read it, so a long-lived event object stays accurate.
availability
How the event shows on a schedule: "busy", "free", "tentative", "unavailable",
or "notSupported" when its calendar doesn't support availability.
Methods
toJSON() -> object
Returns a plain object holding all of the event's properties, for JSON serialisation.
JSON.stringify() calls this automatically, so you rarely need to call it yourself.
toJSON() -> object
| Field | Type | Description |
|---|---|---|
| id | string | |
| externalID | string | null | |
| title | string | |
| location | string | null | |
| notes | string | null | |
| url | string | null | |
| startDate | Date | |
| endDate | Date | |
| occurrenceDate | Date | null | |
| isAllDay | boolean | |
| timeZone | string | null | |
| isActive | boolean | |
| isRecurring | boolean | |
| isDetached | boolean | |
| status | "none" | "confirmed" | "tentative" | "canceled" | |
| availability | "busy" | "free" | "tentative" | "unavailable" | "notSupported" | |
| calendarID | string | null | |
| calendarTitle | string | null |
console.log(JSON.stringify(hs.eventkit.eventsToday(), null, 2))