Skip to content

Instantly share code, notes, and snippets.

@varunlalan
Created August 21, 2013 15:50
Show Gist options
  • Save varunlalan/6296249 to your computer and use it in GitHub Desktop.
Save varunlalan/6296249 to your computer and use it in GitHub Desktop.
Edit "All following events" in recurring event series.
# Steps:
# 1. Get following dates
# * start date of the event series(start_date).
# * date of event being edited(current_date).
# * previous date of occurrence from current_date(previous_current_date).
# * end date of event series(end_date) - can be nil.
#
# The series would look like:
# start_date..............previous_current_date current_date..............end_date
#
# 2. We will break the series in to parts.
# First being from start_date to previous_date.
# Another being current_date to end_date.
#
irb> rrule = existing_event.schedule.rrules.first
# Restricting series to previous_current_date to generate first event series.
irb> existing_event.schedule = IceCube::Schedule.new(rrule.until(previous_current_date))
irb> existing_event.save
# Create new event series from current_date with updated params.
# You need to regenerate the rule and schedule from the params as it is possible to update repeats from the current_date.
# Same code for creating new event will be executed here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment