Add the Chronological

This commit is contained in:
2026-02-16 13:39:26 +01:00
parent c091ed1371
commit f1ac693fe8
162 changed files with 25868 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
<?php
namespace dokuwiki\plugin\luxtools;
/**
* Builds page template content for chronological day pages.
*/
class ChronologicalDayTemplate
{
/**
* Build a German date heading template for a canonical day ID.
*
* Example output:
* ====== Freitag, 13. Februar 2026 ======
*
* @param string $dayId
* @param string $baseNs
* @return string|null
*/
public static function buildForDayId(string $dayId, string $baseNs = 'chronological'): ?string
{
$parts = ChronoID::parseDayId($dayId, $baseNs);
if ($parts === null) return null;
$formatted = self::formatGermanDate($parts['year'], $parts['month'], $parts['day']);
return '====== ' . $formatted . " ======\n\n";
}
/**
* Format date with German day/month names and style:
* Freitag, 13. Februar 2026
*
* @param int $year
* @param int $month
* @param int $day
* @return string
*/
protected static function formatGermanDate(int $year, int $month, int $day): string
{
$weekdays = [
1 => 'Montag',
2 => 'Dienstag',
3 => 'Mittwoch',
4 => 'Donnerstag',
5 => 'Freitag',
6 => 'Samstag',
7 => 'Sonntag',
];
$months = [
1 => 'Januar',
2 => 'Februar',
3 => 'März',
4 => 'April',
5 => 'Mai',
6 => 'Juni',
7 => 'Juli',
8 => 'August',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Dezember',
];
$weekdayIndex = (int)date('N', mktime(0, 0, 0, $month, $day, $year));
$weekday = $weekdays[$weekdayIndex] ?? '';
$monthName = $months[$month] ?? '';
return sprintf('%s, %d. %s %d', $weekday, $day, $monthName, $year);
}
}