Guest User

Untitled

a guest
Feb 20th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. def events(schedule_start, schedule_end)
  2. list = []
  3.  
  4. # Create a screen local time with the schedule start date and the scheduled item's time
  5. this_time = nil
  6. this_time = start_time_for_day(schedule_start)
  7.  
  8. # Check if the first day of the schedule has a match
  9. if(this_time >= self.start_time and schedule_start <= this_time and this_time < schedule_end) then
  10. if (day_match(this_time) and this_time >= self.start_time) then
  11. if !exclusion_match(this_time)
  12. list << hash_for_time(this_time)
  13. end
  14. end
  15. end
  16.  
  17. # Check if every day between today and the end of the desired schedule or the end time of the recurrence is a match
  18. this_time = this_time + 1.day
  19. this_time = start_time_for_day(this_time)
  20. while(this_time < schedule_end and ((self.end_time == nil) or (this_time < self.end_time)))
  21. if (day_match(this_time) and this_time >= self.start_time) then
  22. if !exclusion_match(this_time)
  23. list << hash_for_time(this_time)
  24. end
  25. end
  26. current_time = this_time
  27. this_time = start_time_for_day(this_time + 1.day)
  28. if (this_time <= current_time)
  29. # We are caught in a 25 hour day due to DST switch over
  30. this_time = start_time_for_day(this_time + 25.hours)
  31. end
  32. end
  33.  
  34. return list
  35. end
Add Comment
Please, Sign In to add comment