How to convert iOS date to Rrule format?

How to convert time recurrence(daily, weekly, monthly, etc) to Rrule format and send to backend? Ex:

"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"

Do you using libraries for this in Swift?

1 Like

Corresponding tweet for this thread:

Share link for this tweet.

It depends on where you’re getting your recurrences from? I don’t recall any Apple-specific recurrence mechanisms on the level of calendars like you’re describing. But eventually if you have date objects, you’ll want to use DateComponents to extract the kind of data you’re describing (I don’t know what RRules are)
How you get a DateComponents object is below. See the docs for how to extract the individual months, days etc.

let date = Date()
var calendar = Locale.current.calendar
var dateComponents = calendar.dateComponents(Set<Calendar.Component>(), from: date)
1 Like