diff --git a/content/publiser/index.php b/content/publiser/index.php index 410f1c5..ed1b253 100644 --- a/content/publiser/index.php +++ b/content/publiser/index.php @@ -87,6 +87,36 @@ function publiserPublicUrl(string $section, string $folder): string { return '/' . rawurlencode($section) . '/' . rawurlencode($folder) . '/'; } +/** + * Human-friendly display of a stored publish_at value (e.g. "2026-08-30T14:30", + * the raw format). Mirrors the day/month/year + * order app/plugins/global/languages.php's formatDate() uses for regular + * post dates, extended with a time-of-day. Only for display - never use + * this for the datetime-local input's own value attribute, which must stay + * in machine format. + */ +function publiserNorwegianDate(int $ts): string { + static $months = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember']; + $day = (int)date('j', $ts); + $month = $months[(int)date('n', $ts) - 1]; + return "{$day}. {$month} " . date('Y', $ts); +} + +/** Human-friendly display of a date-only value (e.g. "2026-08-25"). Never + * use this for the value attribute, which must stay ISO. */ +function publiserFormatDate(?string $raw): string { + if (!$raw) return ''; + $ts = strtotime($raw); + return $ts === false ? $raw : publiserNorwegianDate($ts); +} + +function publiserFormatScheduleTime(?string $raw): string { + if (!$raw) return ''; + $ts = strtotime($raw); + if ($ts === false) return $raw; + return publiserNorwegianDate($ts) . ' kl. ' . date('H:i', $ts); +} + function publiserImageUrl(string $location, string $section, string $folder, string $filename): string { if ($location === 'live') { return '/' . rawurlencode($section) . '/' . rawurlencode($folder) . '/' . rawurlencode($filename); @@ -482,9 +512,9 @@ function publiserRenderList(string $csrf): void {
- + - · publiseres + · publiseres
@@ -696,7 +726,7 @@ function publiserRenderEditor(string $csrf): void { -

Planlagt:

+

Planlagt: