-
Notifications
You must be signed in to change notification settings - Fork 129
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
Make use of until parameter in nextMonthly function #532
Make use of until parameter in nextMonthly function #532
Conversation
Thanks for the PR. Could you add unit test which fails without your fix? |
The problem is that this is a performance issue... // To prevent running this forever (better: until we hit the max date of DateTimeImmutable) we simply
// stop at 9999-12-31. Looks like the year 10000 problem is not solved in php ....
if ($this->currentDate->getTimestamp() > 253402300799) {
$this->currentDate = null;
return;
} But it could stop the loop as soon as it arrives the // For some reason the "until" parameter was not being used here,
// that's why the workaround of the 10000 year bug was needed at all
// let's stop it before the "until" parameter date
if ($this->until && $this->currentDate->getTimestamp() >= $this->until->getTimestamp()) {
return;
} In both cases the result is gonna be the same, but the process will be much faster with my purposed fix. NOTE: Obviously, this is only working when the Now i have runned the tests, found an error and fixed it, but I don't know the right way of creating a test for this case since it's a performance issue... I don't want to create a test using the time as a parameter to fail the test... any idea? |
Codecov Report
@@ Coverage Diff @@
## master #532 +/- ##
=========================================
Coverage 98.69% 98.69%
- Complexity 1757 1759 +2
=========================================
Files 66 66
Lines 4277 4279 +2
=========================================
+ Hits 4221 4223 +2
Misses 56 56
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hello there,
I've felt the need of this PR becauase of a buggy event:
FREQ=MONTHLY;
INTERVAL=1;
BYMONTHDAY=2;
BYDAY=2WE;
WKST=WE;
UNTIL=20211214T000000Z
The "Until" was not being taken into account, so it was falling into the 10000 year problem.