From 5c260d82f48a492232dc0e8ea3aee2832b44dacc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 13 Feb 2023 20:58:10 +0100 Subject: [PATCH] Fix Deprecated message Instead of adding a new dynamic property to the DateInterval-Object, a new var is created which stores the weeks. Inside the `foreach` a handler is created by checking, if the current `$key` is `w` for weeks. --- bl-kernel/page.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 65041b5b..6cbd6774 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -663,8 +663,8 @@ class Page { $past = new DateTime($this->getValue('dateRaw')); $elapsed = $current->diff($past); - $elapsed->w = floor($elapsed->d / 7); - $elapsed->d -= $elapsed->w * 7; + $weeks = floor($elapsed->d / 7); + $elapsed->d -= $weeks * 7; $string = array( 'y' => $language->g('year'), @@ -677,8 +677,11 @@ class Page { ); foreach ($string as $key => &$value) { - if ($elapsed->$key) { - $value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : ' '); + + $handle_type = 'w' === $key ? $weeks : $elapsed->$key; + + if ($handle_type) { + $value = $handle_type . ' ' . $value . ($handle_type > 1 ? 's' : ' '); } else { unset($string[$key]); }