-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Getting first upcoming and one past occurrence? #60
Comments
Well getOccurrences and getOcurrencesBetween get a $limit parameter, is that what you want? |
I just want to get the first upcoming and last past date... getOccurrences gives all dates and i want to avoid loop to find first upcoming date. |
What about |
Thank you for your quick response and workaround, i will give it a try. |
I have another scenario, i will be grateful if you may give me workaround? i want to get nth occurrence one way is i change the limit and array_pop like you did previously but lets say nth number is 500 or even higher in this case performance is the question especially memory? |
You would have to test the performance. To get the 500th occurrence after a date there is no other way but to calculate all occurrences to that date, and then 500 occurrences after that date (this is due to how RRULE work), which is was getOccurrencesBetween will do. That being said 500 is really a lot - even for a daily event that's almost 2 years. What is your need exactly? |
I have an event page where i display the current event details and navigation for next and previous occurrence. I know the chances are less or maybe none that user will get to 500th occurrence. Follow this: Lets say today is 20th occurrence now to get one previous date i will do $rrule->getOccurrencesBetween( null, $current ); and will get all past dates. I thought it would be easier if we can simply get nth occurrence instead? Oh One thing previous occurrence is on second last index when we do $rrule->getOccurrencesBetween( null, $current ); Please let me know if you need more clarification? BTW loved your work. |
Yes I agree, the interface could be made easier for this use case, with some helper functions. I'll have a look when I have a moment.
Only if $current itself matches the rule I think? |
Yes that is correct. |
Hello, I added the helpers into master. Please check version 2.0.0-rc1 and give me your feedback! |
You are awesome! |
Is there a way to get only one upcoming and past occurrence? instead of all occurrences?
The text was updated successfully, but these errors were encountered: