system.kanoa.schedule.rruleToDates(rruleStr, startDate, afterDate, maxResults, timeZone)
Returns the next occurrences of a recurrence rule (RRULE), expanded in a time zone (the gateway's unless you pass timeZone) so an occurrence's time of day stays the same across daylight-saving changes. Accepts the CMMS editor's dialect (BYWEEKDAY, TU(2), local UNTIL) or RFC 5545. Returns an empty list for an invalid or ended rule.
Parameters
rruleStr String: i.e. 'FREQ=WEEKLY;INTERVAL=1;BYWEEKDAY=MO,WE'
startDate DateTime: First possible occurrence; its time of day is every occurrence's time of day
afterDate DateTime: Only occurrences after this date (exclusive). None includes startDate itself
maxResults Integer: How many occurrences to return (None means 1, at most 1000)
timeZone String: Optional. The time zone the rule's times of day are in, as an IANA id ('America/Los_Angeles') or a SQL Server name ('Pacific Standard Time'). Pass the session's zone to preview a rule as the user sees it, or the asset's site zone to match what the schedulers create. None or an unknown name uses the gateway's time zone
Returns
dates list[datetime]
Example
rruleStr = 'rruleStr'
startDate = system.date.now()
afterDate = system.date.now()
maxResults = 1
dates = system.kanoa.schedule.rruleToDates(rruleStr, startDate, afterDate, maxResults)
# Weekdays at 08:00 in the plant's time zone, whatever the gateway's zone is
dates = system.kanoa.schedule.rruleToDates('FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR', startDate, None, 5, 'America/Chicago')