diff --git a/app/pages.php b/app/pages.php index 17a22e2..d23fe7f 100644 --- a/app/pages.php +++ b/app/pages.php @@ -418,19 +418,24 @@ function page_calendar(array $user): void $employeeId = query_int('employee'); $showCancelled = query_string('cancelled') === '1'; - // Startwoche: Montag der Woche, in der $date liegt. - $focusFrom = week_start($date); - $focusTo = add_days($focusFrom, CALENDAR_WEEKS * 7 - 1); - if ($view === 'day') { + $focusFrom = $date; $from = $to = $date; } elseif ($view === 'month') { - $from = month_start($date); + $focusFrom = month_start($date); + $from = $focusFrom; $to = month_end($date); + if (client_is_mobile()) { + // Smartphone: auch im Monat ± 2 Monate rendern, damit sich der + // Kalender seitlich durchwischen lässt. + $from = date_obj($focusFrom)->modify('-' . CALENDAR_MOBILE_MONTHS . ' months')->format('Y-m-d'); + $to = date_obj($focusFrom)->modify('+' . (CALENDAR_MOBILE_MONTHS + 1) . ' months')->modify('-1 day')->format('Y-m-d'); + } } else { // Vier Kalenderwochen ab dem Montag der Woche, in der $date liegt. + $focusFrom = week_start($date); $from = $focusFrom; - $to = $focusTo; + $to = add_days($focusFrom, CALENDAR_WEEKS * 7 - 1); if (client_is_mobile()) { // Smartphone: mehr Wochen rendern, damit sich der Kalender nach // links und rechts wischen lässt (± 2 Monate um die Startwoche). @@ -505,8 +510,9 @@ function page_calendar(array $user): void if ($view === 'day') { $title = fmt_date_long($date); } elseif ($view === 'weeks') { - $title = 'KW ' . date_obj($focusFrom)->format('W') . '–' . date_obj($focusTo)->format('W') - . ' · ' . fmt_date_range($focusFrom, $focusTo); + $title = 'KW ' . date_obj($focusFrom)->format('W') . '–' + . date_obj(add_days($focusFrom, CALENDAR_WEEKS * 7 - 1))->format('W') + . ' · ' . fmt_date_range($focusFrom, add_days($focusFrom, CALENDAR_WEEKS * 7 - 1)); } else { $title = fmt_month($date); } diff --git a/app/util.php b/app/util.php index 1465b5a..06ccbd5 100644 --- a/app/util.php +++ b/app/util.php @@ -92,7 +92,7 @@ function url(string $path = '/'): string } /** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */ -const DIC_ASSET_VERSION = '22'; +const DIC_ASSET_VERSION = '23'; function asset(string $path): string { diff --git a/web/sw.js b/web/sw.js index a710e46..6319eb2 100644 --- a/web/sw.js +++ b/web/sw.js @@ -6,7 +6,7 @@ * zwischengespeichert, damit niemand veraltete Buchungen sieht. */ -const VERSION = 'dic-v14'; +const VERSION = 'dic-v15'; const CACHE = VERSION; const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, '');