diff --git a/libraries/php-rrule/CHANGELOG.md b/libraries/php-rrule/CHANGELOG.md index d10f728..4f2c055 100755 --- a/libraries/php-rrule/CHANGELOG.md +++ b/libraries/php-rrule/CHANGELOG.md @@ -2,6 +2,17 @@ ## [Unreleased] +## [3.0.0] - 2026-07-29 + +- Drop support for PHP < 7.3 [#119](https://github.com/rlanvin/php-rrule/issues/119) +- Add support for PHP 8.4 + +### Fixed + +- Added a workaround for a Carbon 3 bug that makes occursAt fail in some cases [#164](https://github.com/rlanvin/php-rrule/issues/164) +- Fix RSet not de-duplicating when using array access [#165](https://github.com/rlanvin/php-rrule/issues/165) +- Fix timezone conversion skipped with DateTimeImmutable [#171](https://github.com/rlanvin/php-rrule/pull/171) + ## [2.6.0] - 2025-04-25 ### Added @@ -289,7 +300,8 @@ - First release, everything before that was unversioned (`dev-master` was used). -[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v2.6.0...HEAD +[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v3.0.0...HEAD +[3.0.0]: https://github.com/rlanvin/php-rrule/compare/v2.6.0...v3.0.0 [2.6.0]: https://github.com/rlanvin/php-rrule/compare/v2.5.2...v2.6.0 [2.5.2]: https://github.com/rlanvin/php-rrule/compare/v2.5.1...v2.5.2 [2.5.1]: https://github.com/rlanvin/php-rrule/compare/v2.5.0...v2.5.1 diff --git a/libraries/php-rrule/README.md b/libraries/php-rrule/README.md index 8b0189e..546977c 100755 --- a/libraries/php-rrule/README.md +++ b/libraries/php-rrule/README.md @@ -32,7 +32,7 @@ Complete documentation and more examples are available in [the wiki](https://git ## Requirements -- PHP >= 5.6 +- PHP >= 7.3 - [intl extension](http://php.net/manual/en/book.intl.php) is recommended for `humanReadable()` but not strictly required ## Installation diff --git a/libraries/php-rrule/bin/import_windows_timezones.php b/libraries/php-rrule/bin/import_windows_timezones.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/RRule.php b/libraries/php-rrule/src/RRule.php old mode 100755 new mode 100644 index 64bc6f0..9f2c7c5 --- a/libraries/php-rrule/src/RRule.php +++ b/libraries/php-rrule/src/RRule.php @@ -71,6 +71,30 @@ function is_leap_year($year) return true; } +/** + * Carbon 3 specific workaround - shouldn't be necessary but here we are. + * Original bug: https://github.com/briannesbitt/Carbon/issues/3018 + * Workaround could be removed if the bug is fixed + * + * @see https://github.com/rlanvin/php-rrule/issues/164 + * @return int + */ +function date_interval_days(\DateInterval $interval): int +{ + if ($interval->days !== false) { + return $interval->days; + } + + // if days is false, we might be dealing with Carbon. + // we try to get it from format() instead, and cast it to int + $days = $interval->format('%a'); + if ($days !== '(unknown)' && is_numeric($days)) { + return (int) $days; + } + + throw new \RuntimeException("Unable to get days from DateInterval. This shouldn't happen. If you are using a custom date library, trying passing a normal \DateTime."); +} + /** * Implementation of RRULE as defined by RFC 5545 (iCalendar). * Heavily based on python-dateutil/rrule @@ -582,7 +606,7 @@ public function rfcString($include_timezone = true) // handle unsupported timezones like "+02:00" // we convert them to UTC to generate a valid string // note: there is possibly other weird timezones out there that we should catch - $dtstart->setTimezone(new \DateTimeZone('UTC')); + $dtstart = $dtstart->setTimezone(new \DateTimeZone('UTC')); $timezone_name = 'UTC'; } if (in_array($timezone_name, array('UTC','GMT','Z'))) { @@ -616,13 +640,13 @@ public function rfcString($include_timezone = true) if (! $include_timezone) { $tmp = clone $this->until; // put until on the same timezone as DTSTART - $tmp->setTimeZone($this->dtstart->getTimezone()); + $tmp = $tmp->setTimeZone($this->dtstart->getTimezone()); $parts[] = 'UNTIL='.$tmp->format('Ymd\THis'); } else { // according to the RFC, UNTIL must be in UTC $tmp = clone $this->until; - $tmp->setTimezone(new \DateTimeZone('UTC')); + $tmp = $tmp->setTimezone(new \DateTimeZone('UTC')); $parts[] = 'UNTIL='.$tmp->format('Ymd\THis\Z'); } continue; @@ -746,7 +770,7 @@ public function occursAt($date) { $date = self::parseDate($date); // convert timezone to dtstart timezone for comparison - $date->setTimezone($this->dtstart->getTimezone()); + $date = $date->setTimezone($this->dtstart->getTimezone()); if (in_array($date, $this->cache)) { // in the cache (whether cache is complete or not) @@ -847,7 +871,7 @@ public function occursAt($date) // count nb of days and divide by 7 to get number of weeks // we add some days to align dtstart with wkst $diff = $date->diff($this->dtstart); - $diff = (int) (($diff->days + pymod($this->dtstart->format('N') - $this->wkst,7)) / 7); + $diff = (int) ((date_interval_days($diff) + pymod($this->dtstart->format('N') - $this->wkst,7)) / 7); if ($diff % $this->interval !== 0) { return false; } @@ -855,21 +879,21 @@ public function occursAt($date) case self::DAILY: // count nb of days $diff = $date->diff($this->dtstart); - if ($diff->days % $this->interval !== 0) { + if (date_interval_days($diff) % $this->interval !== 0) { return false; } break; // XXX: I'm not sure the 3 formulas below take the DST into account... case self::HOURLY: $diff = $date->diff($this->dtstart); - $diff = $diff->h + $diff->days * 24; + $diff = $diff->h + date_interval_days($diff) * 24; if ($diff % $this->interval !== 0) { return false; } break; case self::MINUTELY: $diff = $date->diff($this->dtstart); - $diff = $diff->i + $diff->h * 60 + $diff->days * 1440; + $diff = $diff->i + $diff->h * 60 + date_interval_days($diff) * 1440; if ($diff % $this->interval !== 0) { return false; } @@ -877,7 +901,7 @@ public function occursAt($date) case self::SECONDLY: $diff = $date->diff($this->dtstart); // XXX does not account for leap second (should it?) - $diff = $diff->s + $diff->i * 60 + $diff->h * 3600 + $diff->days * 86400; + $diff = $diff->s + $diff->i * 60 + $diff->h * 3600 + date_interval_days($diff) * 86400; if ($diff % $this->interval !== 0) { return false; } diff --git a/libraries/php-rrule/src/RRuleInterface.php b/libraries/php-rrule/src/RRuleInterface.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/RRuleTrait.php b/libraries/php-rrule/src/RRuleTrait.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/RSet.php b/libraries/php-rrule/src/RSet.php old mode 100755 new mode 100644 index 2564563..e81bdb4 --- a/libraries/php-rrule/src/RSet.php +++ b/libraries/php-rrule/src/RSet.php @@ -600,14 +600,15 @@ public function count() #[\ReturnTypeWillChange] public function getIterator() { - $previous_occurrence = null; $total = 0; + $occurrence = null; foreach ($this->cache as $occurrence) { yield clone $occurrence; // since DateTime is not immutable, avoid any problem $total += 1; } + $previous_occurrence = $occurrence; if ($this->rlist_heap === null) { // rrules + rdate diff --git a/libraries/php-rrule/src/RfcParser.php b/libraries/php-rrule/src/RfcParser.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/de.php b/libraries/php-rrule/src/i18n/de.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/en.php b/libraries/php-rrule/src/i18n/en.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/fi.php b/libraries/php-rrule/src/i18n/fi.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/fr.php b/libraries/php-rrule/src/i18n/fr.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/nl.php b/libraries/php-rrule/src/i18n/nl.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/ru.php b/libraries/php-rrule/src/i18n/ru.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/i18n/sv.php b/libraries/php-rrule/src/i18n/sv.php old mode 100755 new mode 100644 diff --git a/libraries/php-rrule/src/tzdata/windows.php b/libraries/php-rrule/src/tzdata/windows.php old mode 100755 new mode 100644 diff --git a/repeating_dates.info b/repeating_dates.info index a5fa398..e6a9281 100644 --- a/repeating_dates.info +++ b/repeating_dates.info @@ -4,5 +4,6 @@ type = module backdrop = 1.x package = Fields tags[] = Fields +php = 7.3 dependencies[] = field