From 5fa13270606f37ee4fb4e9eb78cbe64e3f67bb5a Mon Sep 17 00:00:00 2001 From: lokonli Date: Sat, 9 Apr 2022 13:33:33 +0200 Subject: [PATCH] calendar: fix start moment --- js/components/calendar.js | 16 +++++++++++----- js/loader.js | 2 +- vendor/dashticz/ical/index.php | 6 ++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/js/components/calendar.js b/js/components/calendar.js index 1e44b711..7f7efdfd 100644 --- a/js/components/calendar.js +++ b/js/components/calendar.js @@ -82,6 +82,15 @@ function prepareCalendar(me, key) { me.history = me.lastweek ? 7 : 0; me.update = true; me.isnew = true; + if(me.layout===2) { + var start = me.isoweek ? 'isoweek' : 'week'; + me.startMoment = moment() + .startOf(start) + .subtract(me.history, 'days'); + } + else + me.startMoment = moment() + .subtract(me.history, 'days'); cal[key] = me; if (cal[key].icalurls > 1) { @@ -141,7 +150,7 @@ function getCalendarData(key, calendars, isnew, ishol) { if ( parseFloat(enddate) >= - moment().subtract(cal[key].history, 'days').format('X') + cal[key].startMoment.format('X') ) { if (!isDefined(events[ev.start])) events[ev.start] = []; @@ -234,10 +243,7 @@ function generateCalendar(key, isnew, ishol) { }); $(cal[key].mountPoint + ' td').each(function (i, obj) { - var start = cal[key].isoweek ? 'isoweek' : 'week'; - var dt = moment() - .startOf(start) - .subtract(cal[key].history, 'days') + var dt = moment(cal[key].startMoment) .add(i, 'days'); $(obj).attr('data-id', dt); $(obj).find('div').first().html(dt.format('ddd DD MMM')); diff --git a/js/loader.js b/js/loader.js index 6bcb11e7..ef6a77e4 100644 --- a/js/loader.js +++ b/js/loader.js @@ -1,6 +1,6 @@ /*global loadFiles dashtype */ -var _DASHTICZ_VERSION=44; +var _DASHTICZ_VERSION=45; var head = document.getElementsByTagName('head')[0], script = document.createElement('script'); diff --git a/vendor/dashticz/ical/index.php b/vendor/dashticz/ical/index.php index a836fc91..5cdf4647 100644 --- a/vendor/dashticz/ical/index.php +++ b/vendor/dashticz/ical/index.php @@ -162,7 +162,7 @@ function icaljg($ICS, $MAXITEMS, $HISTORY) { 'defaultWeekStart' => 'MO', // Default value 'disableCharacterReplacement' => false, // Default value 'filterDaysAfter' => 365, // Default value - 'filterDaysBefore' => (int)$HISTORY+2, + 'filterDaysBefore' => (int)$HISTORY+8, //for the calendar view we may need one additional week 'skipRecurrence' => false, // Default value )); // $ical->initFile('ICal.ics'); @@ -201,7 +201,6 @@ public function eventsFromInterval($interval) $end=$start; $duration = $end-$start; - if ($end>time()-((int)$HISTORY*24*3600)) { $jsEvt = array( "id" => ($id++), "title" => $event->summary, @@ -214,9 +213,8 @@ public function eventsFromInterval($interval) /* $a=array(); array_push($a,$ev["ATTENDEE"]); */ $data[] = $jsEvt; - if ($id>=$MAXITEMS) + if ($id>=500) //we limit to 500 events. Should be sufficient ... break; - } } return $data; } catch (\Exception $e) {