calendar.addEvent()

Type Function
Return value none
Revision Release 2024.3703
Keywords calendar, event, add, addEvent
See also calendar.*

Overview

calendar.addEvent() adds event with specified properties.

Syntax

calendar.addEvent( params )
params (required)

Table. Table containing call parameters - see next section for details.

Parameters table reference

listener (optional)

Listener. Listener that will receive event event.

calendarId (optional)

String. Calendar identifier where calendar event should be added. Default calendar would be used if not specified.

title (optional)

String. Title for new calendar event.

startDate (optional)

Number. Start date for new calendar event in Unix time format.

endDate (optional)

Number. End date for new calendar event in Unix time format.

location (optional)

String. Location for new calendar event.

allDay (optional)

Boolean. Boolean value, where true means that new calendar event should last all day and false otherwise.

repeatFrequency (optional)

String. Recurrency frequency for new calendar event. Valid values are: day, week, month and year. This field must be combined with repeatEndDate.

repeatEndDate (optional)

Number. Recurrency end date for new calendar event in Unix time format. This field must be combined with repeatFrequency.

alarms (optional)

Table. Lua array, each entry containing number of minutes before event to trigger an alarm.

Example

local calendar = require( "plugin.calendar" )

local unixTimeNow = os.time( os.date( '*t' ) )

local function addEventListener( event )
    -- Handle events here
end

-- Add event with specified properties
calendar.addEvent(
{
    listener = addEventListener,

    title = "Test Event",
    startDate = unixTimeNow + 86400,
    endDate = unixTimeNow + 86400 + 3600,
    alarm = 30,
    repeatFrequency = "day",
    repeatEndDate = unixTimeNow + 604800
}
)