[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Fix calendar day view time range

"Alvin Bauma \(@alvinBM\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a8dbdbf4f2f1_386ee8f1c59177@gitlab-sidekiq-low-urgency-cpu-bound-v2-7f4b5767d6-v72kp.mail>

Alvin Bauma pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
47e0e607 by Alvin Bauma at 2026-08-25T18:07:23+02:00
[BP][FIX] Fix calendar day view time range
---
* [FIX] Fix calendar day view time range

See merge request tikiwiki/tiki!11059

- - - - -


2 changed files:

- lib/calendar/calendarlib.php
- tiki-calendar_setup.php


Changes:

=====================================
lib/calendar/calendarlib.php
=====================================
@@ -161,16 +161,24 @@ class CalendarLib extends TikiLib
         global $prefs;
         $canEditAnything = false;
         $calendars = [];
+        $minHourOfDay = '00:00:00';
+        $maxHourOfDay = '24:00:00';
+        $defaultStartOfDay = max(0, min(24 * 60 * 60, (int)($prefs['calendar_start_day'] ?? 0)));
+        $defaultEndOfDay = max(0, min(24 * 60 * 60, (int)($prefs['calendar_end_day'] ?? 24 * 60 * 60)));
         foreach ($rawcalsData as $calendar) {
             $calendar['perms'] = Perms::get([ 'type' => 'calendar', 'object' => $calendar['calendarId']]);
             $calendars[$calendar['calendarId']] = $calendar;
             // for week and day views
-            $startOfDayUnix = (int)($calendar['startday'] ?? $prefs['calendar_startday'] ?? 0);
+            $startOfDayUnix = max(0, min(24 * 60 * 60, (int)($calendar['startday'] ?? $defaultStartOfDay)));
 
             $startOfDayHour = intdiv($startOfDayUnix, 3600);
             $startOfDayMinute = intdiv($startOfDayUnix % 3600, 60);
             $minHourOfDay = sprintf('%02d:%02d:00', $startOfDayHour, $startOfDayMinute);
-            $endOfDayUnix = (int)($calendar['endday'] ?? 0);
+
+            $endOfDayUnix = max(0, min(24 * 60 * 60, (int)($calendar['endday'] ?? $defaultEndOfDay)));
+            if ($endOfDayUnix <= $startOfDayUnix) {
+                $endOfDayUnix = $defaultEndOfDay > $startOfDayUnix ? $defaultEndOfDay : 24 * 60 * 60;
+            }
             $endOfDayHour = intdiv($endOfDayUnix, 3600);
             $endOfDayMinute = intdiv($endOfDayUnix % 3600, 60);
             $maxHourOfDay = sprintf('%02d:%02d:00', $endOfDayHour, $endOfDayMinute);


=====================================
tiki-calendar_setup.php
=====================================
@@ -419,6 +419,18 @@ if (! function_exists('correct_start_day')) {
 
 global $minHourOfDay, $maxHourOfDay;
 
+$formatHourOfDay = static function ($value, string $fallback): string {
+    if ($value === null || $value === '') {
+        return $fallback;
+    }
+
+    if (is_numeric($value)) {
+        return sprintf('%02d:00:00', (int)$value);
+    }
+
+    return (string)$value;
+};
+
 $slotDuration = '00:' . str_pad($prefs['calendar_timespan'], 2, '0', STR_PAD_LEFT);
 switch ($prefs['calendar_view_mode']) {
     case 'week':
@@ -440,8 +452,8 @@ $smarty->assign(
         'firstDayofWeek'   => $firstDayofWeek,
         'display_timezone' => $prefs['display_timezone'],
         'language'         => Language::getCurrentLanguage(),
-        'minHourOfDay'     => $minHourOfDay ?: "00:00:00",
-        'maxHourOfDay'     => $maxHourOfDay ?: "23:00:00",
+        'minHourOfDay'     => $formatHourOfDay($minHourOfDay, "00:00:00"),
+        'maxHourOfDay'     => $formatHourOfDay($maxHourOfDay, "24:00:00"),
         'slotDuration'     => $slotDuration,
         'initialView'      => $initialView,
         'initialDate'      => "$focus_year-$focus_month-$focus_day",



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/47e0e607d2df8c41e33d9cb7a321dc0a95efa62f

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/47e0e607d2df8c41e33d9cb7a321dc0a95efa62f
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.