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

Add a method to check if a datetime matches an rrule (or rruleset) #81

Open
msdrigg opened this issue Aug 17, 2022 · 4 comments
Open

Add a method to check if a datetime matches an rrule (or rruleset) #81

msdrigg opened this issue Aug 17, 2022 · 4 comments

Comments

@msdrigg
Copy link
Contributor

msdrigg commented Aug 17, 2022

Currently this is possible with the iterator, but it could be made a lot more efficient with a dedicated method (and without any of the security concerns that come with the iterator).

@fmeringdal
Copy link
Owner

fmeringdal commented Aug 17, 2022

The iterator is the only way to generate occurrences and every method just builds on top of the iterator. So I am not sure what you mean by "a lot more efficient with a dedicated method". Can you please elaborate on how you would make a method that is more efficient without using the iterator?

EDIT: Oh you probably mean checking if a datetime matches all of the criteria in the rrule?

@msdrigg
Copy link
Contributor Author

msdrigg commented Aug 17, 2022

EDIT: Oh you probably mean checking if a datetime matches all of the criteria in the rrule?

This is exactly what I am looking for.

@msdrigg
Copy link
Contributor Author

msdrigg commented Aug 17, 2022

Basically my problem is this: I want to know if a datetime occurs in my rruleset sequence. Something like:

let in_sequence: bool = rrule.build(dt_start).unwrap().into_iter().find(|val| val == datetime).is_some()

I think if this new method is added, the following code should be equivalent to the check above (please correct me if I am mistaken on this point)

// New Method `check_match` that checks if datetime matches all criteria of the rrule
rrule.validate(dt_start).unwrap().check_match(datetime) && datetime > dt_start

This new check_match function could be a function on RRule<Validated> and/or RRuleSet.

What do you think of this proposal?

@fmeringdal
Copy link
Owner

I think it is an interesting use-case, one which I haven't thought about before. I don't have too much time these days to implement it, but if you want to give it a try I would be happy to help and merge it when ready.

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

No branches or pull requests

2 participants