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.
This commit is contained in:
parent
532140d967
commit
5c260d82f4
1 changed files with 7 additions and 4 deletions
|
@ -663,8 +663,8 @@ class Page {
|
||||||
$past = new DateTime($this->getValue('dateRaw'));
|
$past = new DateTime($this->getValue('dateRaw'));
|
||||||
$elapsed = $current->diff($past);
|
$elapsed = $current->diff($past);
|
||||||
|
|
||||||
$elapsed->w = floor($elapsed->d / 7);
|
$weeks = floor($elapsed->d / 7);
|
||||||
$elapsed->d -= $elapsed->w * 7;
|
$elapsed->d -= $weeks * 7;
|
||||||
|
|
||||||
$string = array(
|
$string = array(
|
||||||
'y' => $language->g('year'),
|
'y' => $language->g('year'),
|
||||||
|
@ -677,8 +677,11 @@ class Page {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($string as $key => &$value) {
|
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 {
|
} else {
|
||||||
unset($string[$key]);
|
unset($string[$key]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue