Update date range handling in newsletter HTML for index.php and wiki.php. Adjusted end date calculation for current month and refined date range display logic to improve clarity and accuracy in article summaries.
This commit is contained in:
28
wiki.php
28
wiki.php
@@ -285,7 +285,7 @@ function newsletterPeriod(string $mode): array
|
||||
|
||||
if ($mode === 'current_month') {
|
||||
$start = $now->modify('first day of this month')->setTime(0, 0, 0);
|
||||
$end = $now->modify('first day of next month')->setTime(0, 0, 0);
|
||||
$end = $now->modify('tomorrow')->setTime(0, 0, 0);
|
||||
} else {
|
||||
$start = $now->modify('first day of previous month')->setTime(0, 0, 0);
|
||||
$end = $now->modify('first day of this month')->setTime(0, 0, 0);
|
||||
@@ -344,11 +344,31 @@ function buildNewsletterHtml(array $config, array $articles, string $periodLabel
|
||||
$replyEmail = trim((string)($config['reply_to'] ?: $config['from_email']));
|
||||
$replyHref = 'mailto:' . $replyEmail;
|
||||
$summaryText = $count === 1
|
||||
? 'Im Zeitraum ' . h($periodLabel) . ' wurde 1 neuer Wiki-Artikel veröffentlicht.'
|
||||
: 'Im Zeitraum ' . h($periodLabel) . ' wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.';
|
||||
? 'In diesem Zeitraum wurde 1 neuer Wiki-Artikel veröffentlicht.'
|
||||
: 'In diesem Zeitraum wurden ' . $count . ' neue Wiki-Artikel veröffentlicht.';
|
||||
|
||||
[$periodStart, $periodEnd] = newsletterPeriod((string)$config['period_mode']);
|
||||
$dateRangeText = 'vom ' . $periodStart->format('d.m.Y') . ' bis ' . $periodEnd->format('d.m.Y');
|
||||
$rangeEnd = $periodEnd;
|
||||
if (($config['period_mode'] ?? '') === 'current_month') {
|
||||
$rangeEnd = new DateTimeImmutable('today');
|
||||
}
|
||||
$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 = '';
|
||||
if ($count === 0) {
|
||||
|
||||
Reference in New Issue
Block a user