From 0832b9b9794a955b08fd2a51f0caa290acac0477 Mon Sep 17 00:00:00 2001 From: "St. Frank" Date: Sun, 14 Jun 2026 14:59:19 +0200 Subject: [PATCH 1/3] Bug Multi-Day Events https://github.com/donatj/SimpleCalendar/issues/3 This fixes the bug described in Issue 3 Co-Authored-By: St. Frank --- src/SimpleCalendar.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/SimpleCalendar.php diff --git a/src/SimpleCalendar.php b/src/SimpleCalendar.php old mode 100644 new mode 100755 index 4a15f2d..86d9c84 --- a/src/SimpleCalendar.php +++ b/src/SimpleCalendar.php @@ -168,10 +168,33 @@ public function addDailyHtml( string $html, $startDate, $endDate = null ) : void $working = (new \DateTimeImmutable)->setTimestamp($start->getTimestamp()); + $count_days = $start->diff($end); + do { $tDate = getdate($working->getTimestamp()); - $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + if ($count_days->days > 0) + { + if ($start->format('Ynj') == ($tDate['year'].$tDate['mon'].$tDate['mday'])) + { + if ($start->format('N') != $this->offset) + { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + } + } + elseif ($tDate['wday'] == $this->offset) + { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + } + else + { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = ' '; + } + } + else + { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + } $working = $working->add(new \DateInterval('P1D')); } while( $working->getTimestamp() < $end->getTimestamp() + 1 ); From 054d0db682f651f88e9d2ef4d4708c9c4f089f2f Mon Sep 17 00:00:00 2001 From: "St. Frank" Date: Mon, 15 Jun 2026 09:51:24 +0200 Subject: [PATCH 2/3] Bug Multi-Day Events Number of days of correction. --- src/SimpleCalendar.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SimpleCalendar.php b/src/SimpleCalendar.php index 86d9c84..9f04033 100755 --- a/src/SimpleCalendar.php +++ b/src/SimpleCalendar.php @@ -168,14 +168,20 @@ public function addDailyHtml( string $html, $startDate, $endDate = null ) : void $working = (new \DateTimeImmutable)->setTimestamp($start->getTimestamp()); - $count_days = $start->diff($end); + $count_days = ($start->diff($end)->days); do { $tDate = getdate($working->getTimestamp()); - if ($count_days->days > 0) + + + if ($count_days == 1) + { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + } + else { - if ($start->format('Ynj') == ($tDate['year'].$tDate['mon'].$tDate['mday'])) + if ($start->format('Y-n-j') == ($tDate['year'] . '-' . $tDate['mon'] . '-' . $tDate['mday'])) { if ($start->format('N') != $this->offset) { @@ -191,10 +197,6 @@ public function addDailyHtml( string $html, $startDate, $endDate = null ) : void $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = ' '; } } - else - { - $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; - } $working = $working->add(new \DateInterval('P1D')); } while( $working->getTimestamp() < $end->getTimestamp() + 1 ); From 24258711fde0fc12a96eab761752b3f6f65ea54a Mon Sep 17 00:00:00 2001 From: "St. Frank" Date: Mon, 22 Jun 2026 23:30:55 +0200 Subject: [PATCH 3/3] code cleaned up @wintstar --- src/SimpleCalendar.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/SimpleCalendar.php b/src/SimpleCalendar.php index 9f04033..4ecbada 100755 --- a/src/SimpleCalendar.php +++ b/src/SimpleCalendar.php @@ -173,27 +173,14 @@ public function addDailyHtml( string $html, $startDate, $endDate = null ) : void do { $tDate = getdate($working->getTimestamp()); - - - if ($count_days == 1) - { + if ($count_days == 1) { $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; - } - else - { - if ($start->format('Y-n-j') == ($tDate['year'] . '-' . $tDate['mon'] . '-' . $tDate['mday'])) - { - if ($start->format('N') != $this->offset) - { - $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; - } - } - elseif ($tDate['wday'] == $this->offset) - { + } else { + if ($start->format('Y-n-j') == ($tDate['year'] . '-' . $tDate['mon'] . '-' . $tDate['mday'])) { $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; - } - else - { + } elseif ($tDate['wday'] == $this->offset) { + $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html; + } else { $this->dailyHtml[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = ' '; } }