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.
This commit is contained in:
Andrew Ruthven 2022-12-15 18:08:12 +13:00 committed by Andrew Ruthven
parent 6e68c221e9
commit a323ba8dae
2 changed files with 9 additions and 12 deletions

View File

@ -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();

View File

@ -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: