Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def events(schedule_start, schedule_end)
- list = []
- # Create a screen local time with the schedule start date and the scheduled item's time
- this_time = nil
- this_time = start_time_for_day(schedule_start)
- # Check if the first day of the schedule has a match
- if(this_time >= self.start_time and schedule_start <= this_time and this_time < schedule_end) then
- if (day_match(this_time) and this_time >= self.start_time) then
- if !exclusion_match(this_time)
- list << hash_for_time(this_time)
- end
- end
- end
- # Check if every day between today and the end of the desired schedule or the end time of the recurrence is a match
- this_time = this_time + 1.day
- this_time = start_time_for_day(this_time)
- while(this_time < schedule_end and ((self.end_time == nil) or (this_time < self.end_time)))
- if (day_match(this_time) and this_time >= self.start_time) then
- if !exclusion_match(this_time)
- list << hash_for_time(this_time)
- end
- end
- current_time = this_time
- this_time = start_time_for_day(this_time + 1.day)
- if (this_time <= current_time)
- # We are caught in a 25 hour day due to DST switch over
- this_time = start_time_for_day(this_time + 25.hours)
- end
- end
- return list
- end
Add Comment
Please, Sign In to add comment