Skip to content
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

Access to UNTIL within occurances #63

Open
mitsion opened this issue Jan 11, 2019 · 7 comments
Open

Access to UNTIL within occurances #63

mitsion opened this issue Jan 11, 2019 · 7 comments

Comments

@mitsion
Copy link

mitsion commented Jan 11, 2019

First I'd like to thank you for your work on this very useful library.

This is actually not an issue, but I'd like to access the "UNTIL" property in occurrences object (which now contains only date object). I'm using your library for event entry and (miss)use the "DTSTART" and "UNTIL" for start and end timestamp, because of that I need access to the UNTIL so that I can get the correct end time (UNTIL is provided as a timestamp).
I've been looking at the source and trying to find a way to add the "UNTIL" property (which is only available in the "rrule" object) to the "occurrence" object, but have failed to do so (simply don't know how to merge the property into "rlist_iterator").

rlanvin added a commit that referenced this issue Jan 13, 2019
@rlanvin
Copy link
Owner

rlanvin commented Jan 13, 2019

Hello,

I have had this question multiple time. The easiest way to do is it to implement a proxy class on top of RRule to convert the occurrence from DateTime objects into whatever you want.

Check the branch proxy, I created a basic example for this purpose. You just need to pass a factory method to the Proxy class. For example:

$proxy = new Proxy(
	new RRule([
		'FREQ' => 'MONTHLY',
		'COUNT' => 3,
		'BYMONTHDAY' => 31,
		'DTSTART' => '1997-09-02'
	]),
	function (\DateTimeInterface $occurrence) {
		return new \RRule\Event($occurrence, 3600);
	}
);

When you use $proxy you will get \RRule\Event objects instead of a DateTime.

Happy to get feedback. If this is useful, I'll add it to master.

@crantodev
Copy link

Hello @rlanvin,

is there any intention to include this proxy feature soon?

@rlanvin
Copy link
Owner

rlanvin commented Apr 2, 2019

@danielmoracr I'm just waiting for someone, anyone who has this use case and who wants to try it to provide some feedback. I don't have this use case myself so I don't know if the solution I wrote is useful or not.
If you want to give it a try, I'm happy to support and add it to the next release if it proves useful.

@bor0
Copy link

bor0 commented Oct 17, 2019

Hi @rlanvin, this is great, thanks for your work.

However, I found an issue with the proxy branch. Please refer to the following example code.

We're setting two events there: one that starts at 00:00 and lasts until 00:59 and another one that starts at 01:00 and lasts until 01:59. The issue is that getOccurrencesBetween( '2019-10-01 00:30:00', '2019-10-01 00:39:00' ) returns an empty array, while it should return the first event because it has intersecting times with it.

@ed-fruty
Copy link

Any updates?

@bor0, @rlanvin , can you share your Proxy implementation ?

@rlanvin
Copy link
Owner

rlanvin commented Dec 16, 2019

Hey, sorry I completely missed the notification for the previous message.
@ed-fruty The Proxy is a branch in this repo (called "proxy"), but it's based on an older master, I will merge master into it.
@bor0 Thanks for the bug report, I'll have a look.

@bor0
Copy link

bor0 commented Apr 5, 2020

@rlanvin I gave this another try, seems to be working fine! I had an error in my implementation. I updated the Gist and it works fine.

Any chance of merging proxy into master? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants