From a323ba8dae7a9cf7254787f882e3524d168dd418 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Thu, 15 Dec 2022 18:08:12 +1300 Subject: [PATCH] Don't change the day of the month to 28, if it is > 28 Gosh. The logic was saying, if the modified date has a day of the month > 28, change it to 28. Which is rather odd. Don't do that. This closes #248. It also fixes a bug with FREQ=MONTHLY;BYMONTHDAY=-1 as it turns out. --- inc/RRule.php | 3 --- .../regression-suite/0831-Spec-RRULE-1.result | 18 +++++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/inc/RRule.php b/inc/RRule.php index b3ef54b0..fa0fb80c 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -369,9 +369,6 @@ class RepeatRuleDateTime extends DateTime { if ( DEBUG_RRULE) dbg_error_log( 'RRULE', "Modify '%s' by: >>%s<<\n", $this->__toString(), $interval ); // print_r($this); if ( !isset($interval) || $interval == '' ) $interval = '1 day'; - if ( parent::format('d') > 28 && strstr($interval,'month') !== false ) { - $this->setDate(null,null,28); - } parent::modify($interval); if (DEBUG_RRULE) dbg_error_log( 'RRULE', "Modified to '%s'", $this->__toString() ); return $this->__toString(); diff --git a/testing/tests/regression-suite/0831-Spec-RRULE-1.result b/testing/tests/regression-suite/0831-Spec-RRULE-1.result index 209476eb..e3079b9e 100644 --- a/testing/tests/regression-suite/0831-Spec-RRULE-1.result +++ b/testing/tests/regression-suite/0831-Spec-RRULE-1.result @@ -258,17 +258,17 @@ SQL Result: =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= 20110831 - RRULE:FREQ=MONTHLY;BYMONTHDAY=-1 The last day of each month -PHP & SQL results are identical (-: +PHP & SQL results differ :-( PHP Result: - 2011-08-31 00:00:00 2011-09-30 00:00:00 2011-10-31 00:00:00 2011-11-30 00:00:00 - 2011-12-31 00:00:00 2012-01-31 00:00:00 2012-02-29 00:00:00 2012-03-31 00:00:00 - 2012-04-30 00:00:00 2012-05-31 00:00:00 2012-06-30 00:00:00 2012-07-31 00:00:00 - 2012-08-31 00:00:00 2012-09-30 00:00:00 2012-10-31 00:00:00 2012-11-30 00:00:00 - 2012-12-31 00:00:00 2013-01-31 00:00:00 2013-02-28 00:00:00 2013-03-31 00:00:00 - 2013-04-30 00:00:00 2013-05-31 00:00:00 2013-06-30 00:00:00 2013-07-31 00:00:00 - 2013-08-31 00:00:00 2013-09-30 00:00:00 2013-10-31 00:00:00 2013-11-30 00:00:00 - 2013-12-31 00:00:00 2014-01-31 00:00:00 + 2011-08-31 00:00:00 2011-10-31 00:00:00 2011-11-30 00:00:00 2011-12-31 00:00:00 + 2012-01-31 00:00:00 2012-02-29 00:00:00 2012-03-31 00:00:00 2012-04-30 00:00:00 + 2012-05-31 00:00:00 2012-06-30 00:00:00 2012-07-31 00:00:00 2012-08-31 00:00:00 + 2012-09-30 00:00:00 2012-10-31 00:00:00 2012-11-30 00:00:00 2012-12-31 00:00:00 + 2013-01-31 00:00:00 2013-02-28 00:00:00 2013-03-31 00:00:00 2013-04-30 00:00:00 + 2013-05-31 00:00:00 2013-06-30 00:00:00 2013-07-31 00:00:00 2013-08-31 00:00:00 + 2013-09-30 00:00:00 2013-10-31 00:00:00 2013-11-30 00:00:00 2013-12-31 00:00:00 + 2014-01-31 00:00:00 2014-02-28 00:00:00 SQL Result: