Created
August 21, 2013 15:50
-
-
Save varunlalan/6296249 to your computer and use it in GitHub Desktop.
Edit "All following events" in recurring event series.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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