[Bps-public-commit] rtx-calendar branch multiple-days-events-2 created. 1.05-21-gae3c230
BPS Git Server
git at git.bestpractical.com
Thu Nov 16 14:57:01 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtx-calendar".
The branch, multiple-days-events-2 has been created
at ae3c2303fbe5a0e7cde25fc82c2a24cc9c168155 (commit)
- Log -----------------------------------------------------------------
commit ae3c2303fbe5a0e7cde25fc82c2a24cc9c168155
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Thu Nov 16 11:56:34 2023 -0300
Fix switching to January
There was a bug when switching from February to January or December to
January because we send 0 to represent January and it was interpreted as
false.
Now we check if the month argument is defined and if not we set it to
the current month.
diff --git a/html/Elements/Calendar b/html/Elements/Calendar
index 4af069e..3c23762 100644
--- a/html/Elements/Calendar
+++ b/html/Elements/Calendar
@@ -192,7 +192,7 @@ while ($date <= $end) {
</div>
<%INIT>
my $NotFirstAccess = $DECODED_ARGS->{NotFirstAccess};
-my $Month = $DECODED_ARGS->{Month} || (localtime)[4];
+my $Month = $DECODED_ARGS->{Month} // (localtime)[4];
my $Year = $DECODED_ARGS->{Year} || (localtime)[5] + 1900;
my $Query = $DECODED_ARGS->{Query};
my $Format = $DECODED_ARGS->{Format};
commit 8b28a35ec32be1d0fc1e8b41ae0621125a6b59b0
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Fri Nov 3 15:09:11 2023 -0300
Prevent infinite loops when rendering multiple days events
This patch prevents infinite or long loops when rendering multiple days
events if user set end date to a date many years in the future.
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 46eeec1..be2486b 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -140,7 +140,11 @@ sub FindTickets {
my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
my $first_day = 1;
- while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+ # We want to prevent infinite loops if user for some reason
+ # set a future date for year 3000 or something like that
+ my $prevent_infinite_loop = 0;
+ while ( ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+ && ( $prevent_infinite_loop++ < 10000 ) )
{
my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
commit 552a281e157fd5d75b66a4cb56035f9b2994a1fb
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Fri Nov 3 15:02:53 2023 -0300
Fix bug multiple days events not showing correctly
The loop on the code that was checking if an event had multiple days had
a minor bug because it was adding one day to each loop but using
unixtime to check if the event had the next day ahead. That was causing
the last day of the event to be disconnected from the rest if it was
starting at a time lower than the start time of the event.
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index d37cae8..46eeec1 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -138,9 +138,9 @@ sub FindTickets {
Value => $starts_date->Unix,
);
- my $end_date_unix = $ends_date->Unix;
+ my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
my $first_day = 1;
- while ( $current_date->Unix <= $end_date_unix )
+ while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
{
my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
-----------------------------------------------------------------------
hooks/post-receive
--
rtx-calendar
More information about the Bps-public-commit
mailing list