-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add way to get end_time for occurrences #119
Comments
I think this might be a good start: def end_time_for_occurrence(occurrence)
if all_day?
occurrence.to_date + (start_time.to_date - end_time.to_date)
else
occurrence + (end_time.to_i - start_time.to_i)
end
end |
@dlee much better issue on this one. But I think the problem is the same as your previous issue, you're confusing "end_time" with "duration". The end_time (if I'm reading it correctly) is not the end time per occurrence, it's the end time of the schedule, which I do not think is what you want. |
@jfelchner end_time is supposed to be the end_time for the first occurrence. With that, ice_cube should be able to deduce the end_times for all other occurrences. |
@dlee I don't get it. What should be used to set the bounding limit for the schedule's occurrences if you don't want them to repeat forever? Say I want my weekly, hour-long event to stop after Dec 31? That's what Occurrences are just time objects pointing to the start of each occurrence; they don't have an "end time". I haven't had any problems with the existing: That said, what about methods like:
These could simply advance the occurrence times by the duration. Either that, or implement an Occurrence class as a Time decorator so it can have an
That's what I would do... |
@avit |
@avit @dlee You two are both right. The iCal spec specifies that you can specify the end time for an occurrence but you can ALSO specify the end time of a schedule. They are two totally separate things. If you specify the end time of the occurrence it calculates the difference between the start time of the schedule and the end time of the occurrence and determines the How that's specified when creating and But I definitely feel like there should be an |
@jfelchner How can both be right? The @avit to answer your question:
You have to use the recurrence rules to add either a repetition count or a last occurrence date ( |
@dlee I wasn't claiming that But I didn't know specifically what the method calls were do it. Thanks for explaining. |
That's because it is, in IceCube, at least. The Honestly, I use IceCube purely in Ruby, not for outputting to iCal so I'm not too familiar with the details of the iCalendar spec. I think @dlee is right about it though: if you read the second paragraph of RRULE description, it's pretty clear about DTEND and IceCube seems to be using it differently:
Given I want lunch 12:00 to 13:00 every day in December:
You can see this is limited to only one occurrence, and it has no duration. However, this works:
The There is probably a more fundamental bug or misunderstanding of the iCalendar spec here... |
Ok, I tried wrapping an Occurrence class around Time, see https://github.com/avit/ice_cube/tree/issues/119-occurrence In order to do time arithmetic transparently ( |
Great. Voting both hands for @avit solution. |
@avit I'm totally fine with your implementation in the way you're calculating the end time when duration in set (ref #120), but monkey-patching
then, again in my opinion, it should be refactored to
or
Also, in |
Agreed - we need to remove the Time patch - preferably by adding a method to IceCube::TimeUtil |
I wanted to see how transparently "Time-like" I could make it so as not to change the existing interface. Unfortunately core Time's minus method doesn't do coercion so there's no built-in However, with ActiveSupport loaded, it should work transparently without yet another monkey patch: their patch of minus_with_coercion has a hook for @seejohnrun, what method were you thinking of adding to TimeUtil? Are you thinking of a |
Schedule occurrences are wrapped in a Time-like object that wraps the start & end time into a single concept. All methods delegate to the occurrence's enclosed start_time so it continues to behave like before. Fixes ice-cube-ruby#119
Right now, when you specify a duration, there's no simple way to get the end_time for all occurrences. You have to calculate it yourself, and that's error-prone for all-day events (especially across daylight saving changes). Even more error prone is when the user provides end_time instead of duration, and the user wants to calculate the end times for other occurrences.
I propose Schedule#end_time_for_occurrence(occurrence) that will automatically return the end_time for a given occurrence, taking into account duration or end_time.
The text was updated successfully, but these errors were encountered: