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

Daily and getOccurrencesBetween #93

Open
davidh71 opened this issue Sep 3, 2022 · 4 comments
Open

Daily and getOccurrencesBetween #93

davidh71 opened this issue Sep 3, 2022 · 4 comments

Comments

@davidh71
Copy link

davidh71 commented Sep 3, 2022

I've just started using the library and it's great! The below doesn't work and I'm wondering if my approach is wrong or a defect.
I would expect to get 2 results back - and get nothing.
Many Thanks!

$r = new When\When();
$r->RFC5545_COMPLIANT = When\When::IGNORE;
$r->startDate(new DateTime("20220902"))
->freq("daily")
->interval( 1 );

$occurrences = $r->getOccurrencesBetween(new DateTime("20220902"),new DateTime("20220904"));
var_dump($r->occurrences);
@davidh71
Copy link
Author

davidh71 commented Sep 6, 2022

found my problem in the above - silly mistake. My apologies

I would like some clarity on the getOccurrencesBetween behavior.
If i run this - i don't get any dates ON, or AFTER the end date

$r->startDate(new DateTime("20220902"))
  ->freq("daily")
  ->interval( 1 );
$occurrences = $r->getOccurrencesBetween(new DateTime("20220903"),new DateTime("20220907"));
var_export($occurrences);

but when i use weekly, it includes days ON the end date

$r->startDate(new DateTime("20220902"))
  ->freq("weekly")
  ->byday("mo,tu,we,th,fr,sa,su")
  ->interval( 1 );

$occurrences = $r->getOccurrencesBetween(new DateTime("20220903"),new DateTime("20220907"));
var_export($occurrences);

Is there a reason 'between' is inconsistent with the end date?

@marcoczen
Copy link

Hi. I noticed the same thing too. Using the latest version of when ( v3.1.5)
So for 'daily' . i just added 1 more day for the $dateEnd.

Weekly does not have this issue.

@tplaner
Copy link
Owner

tplaner commented Jul 15, 2024

Definitely looks like a bug. I'm open to looking at PRs if someone figures out the issue.

@marcoczen
Copy link

marcoczen commented Jul 16, 2024

Wow ... a reply from the man himself.
You have created a great library .... Just 2 php files.... What a genius.

PR -> For php, I am in the noob - intermediate range .... Too dumb for this kind of work.

Once again ... a great library...

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

3 participants