[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Fix calendar day view time range

"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a7ad7882ec44_38542edc75388@gitlab-sidekiq-low-urgency-cpu-bound-v2-84dcc76b6c-hk8r6.mail>

ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
50aea874 by Alvin Bauma at 2026-08-11T07:47:39+00:00
[FIX] Fix calendar day view time range
---
* [FIX] Fix calendar day view time range

See merge request tikiwiki/tiki!10543

- - - - -


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/50aea87462beb287c0e4adcd7ed95532600394ed

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/50aea87462beb287c0e4adcd7ed95532600394ed
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.