From f0ead9f2fa6efe95821caa461b9deb14798fbc66 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Mon, 22 Nov 2021 16:46:39 +0100 Subject: [PATCH 1/2] Remove work-around for bug #81458 --- src/Carbon/Traits/Difference.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Carbon/Traits/Difference.php b/src/Carbon/Traits/Difference.php index 08790902ed..fa7a49fca0 100644 --- a/src/Carbon/Traits/Difference.php +++ b/src/Carbon/Traits/Difference.php @@ -217,7 +217,7 @@ public function diffInWeeks($date = null, $absolute = true) */ public function diffInDays($date = null, $absolute = true) { - return $this->getIntervalDayDiff($this->diff($this->resolveCarbon($date), $absolute)); + return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%a'); } /** @@ -518,7 +518,7 @@ public function floatDiffInDays($date = null, $absolute = true) return $hoursDiff / static::HOURS_PER_DAY; } - $daysDiff = $this->getIntervalDayDiff($interval); + $daysDiff = (int) $interval->format('%r%a'); return $daysDiff + fmod($hoursDiff, static::HOURS_PER_DAY) / static::HOURS_PER_DAY; } @@ -1149,17 +1149,4 @@ public function calendar($referenceTime = null, array $formats = []) return $this->isoFormat((string) $format); } - - private function getIntervalDayDiff(DateInterval $interval): int - { - $daysDiff = (int) $interval->format('%r%a'); - - // Work around PHP 8.1 regression (see https://bugs.php.net/bug.php?id=81458) - if ($daysDiff === 0) { - $daysDiff = ($interval->invert ? -1 : 1) * - ($interval->y * static::DAYS_PER_YEAR + $interval->m * 30 + $interval->d); - } - - return $daysDiff; - } } From ce838b0f90a75b2ba9c9f59daf385e65ba000733 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Mon, 22 Nov 2021 17:14:13 +0100 Subject: [PATCH 2/2] Ignore apt install failure --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adb3c9428c..7e8283245a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,7 +74,8 @@ jobs: - name: Install locales run: | - sudo apt-get update && sudo apt-get install tzdata locales -y && sudo locale-gen fr_FR.UTF-8 sr_ME.UTF-8 ar_AE.UTF-8 zh_TW.UTF-8 zh_CN.UTF-8 yo_NG.UTF-8 en_US.UTF-8 + sudo apt-get update || apt --fix-broken install || echo 'Apt failure ignored' + sudo apt-get install tzdata locales -y && sudo locale-gen fr_FR.UTF-8 sr_ME.UTF-8 ar_AE.UTF-8 zh_TW.UTF-8 zh_CN.UTF-8 yo_NG.UTF-8 en_US.UTF-8 || echo 'Apt failure ignored' - name: Setup Memcached if: matrix.laravel