Remove redundant date range calculation logic from buildNewsletterHtml function in index.php and wiki.php. This cleanup enhances code maintainability by eliminating unnecessary complexity.
This commit is contained in:
16
index.php
16
index.php
@@ -353,22 +353,6 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
|
|||||||
$rangeEnd = new DateTimeImmutable('today');
|
$rangeEnd = new DateTimeImmutable('today');
|
||||||
}
|
}
|
||||||
$dateRangeText = 'vom ' . $periodStart->format('d.m') . ' bis ' . $rangeEnd->format('d.m');
|
$dateRangeText = 'vom ' . $periodStart->format('d.m') . ' bis ' . $rangeEnd->format('d.m');
|
||||||
if ($isTest && !empty($articles)) {
|
|
||||||
$timestamps = [];
|
|
||||||
foreach ($articles as $article) {
|
|
||||||
$date = DateTimeImmutable::createFromFormat('Y-m-d', (string)($article['date'] ?? ''));
|
|
||||||
if ($date instanceof DateTimeImmutable) {
|
|
||||||
$timestamps[] = $date->getTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($timestamps)) {
|
|
||||||
sort($timestamps);
|
|
||||||
$from = (new DateTimeImmutable('@' . (string)$timestamps[0]))->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$to = (new DateTimeImmutable('@' . (string)$timestamps[count($timestamps) - 1]))->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$dateRangeText = 'vom ' . $from->format('d.m') . ' bis ' . $to->format('d.m');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$articleRows = '';
|
$articleRows = '';
|
||||||
if ($count === 0) {
|
if ($count === 0) {
|
||||||
|
|||||||
16
wiki.php
16
wiki.php
@@ -353,22 +353,6 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
|
|||||||
$rangeEnd = new DateTimeImmutable('today');
|
$rangeEnd = new DateTimeImmutable('today');
|
||||||
}
|
}
|
||||||
$dateRangeText = 'vom ' . $periodStart->format('d.m') . ' bis ' . $rangeEnd->format('d.m');
|
$dateRangeText = 'vom ' . $periodStart->format('d.m') . ' bis ' . $rangeEnd->format('d.m');
|
||||||
if ($isTest && !empty($articles)) {
|
|
||||||
$timestamps = [];
|
|
||||||
foreach ($articles as $article) {
|
|
||||||
$date = DateTimeImmutable::createFromFormat('Y-m-d', (string)($article['date'] ?? ''));
|
|
||||||
if ($date instanceof DateTimeImmutable) {
|
|
||||||
$timestamps[] = $date->getTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($timestamps)) {
|
|
||||||
sort($timestamps);
|
|
||||||
$from = (new DateTimeImmutable('@' . (string)$timestamps[0]))->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$to = (new DateTimeImmutable('@' . (string)$timestamps[count($timestamps) - 1]))->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$dateRangeText = 'vom ' . $from->format('d.m') . ' bis ' . $to->format('d.m');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$articleRows = '';
|
$articleRows = '';
|
||||||
if ($count === 0) {
|
if ($count === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user