From ddbeed2ac88b4d88e3c8745fa72553f59ccc3da8 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Wed, 3 Apr 2019 13:46:31 +0200
Subject: added workaround for DST shortcommings of Rivendell


diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 66ae89b..3a01761 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -1324,8 +1324,21 @@ sub create_or_update_schedule_log
     return (undef, $status, $errorstring);
   }
 
+  my $dst_dummy2 = 0;
+  my $dst_dummy3 = 0;
   my @carts = ();
   for my $show (@shows) {
+    ## Rivendell is incredibly stupid and does not handle daylight savings time at all.
+    ## To fix we add a dummy show id to resync with real time at 2:00 and 3:00 in the
+    ## morning, (Macro 20 is updating the display of the current week in RDAirplay)
+    if($dst_dummy2 == 0 && $show->{'START_TIME'} >= 7200) {
+      push @carts, { NUMBER => 20, START_TIME => 7200000, TRANS_TYPE => 2, TIME_TYPE => 1 };
+      $dst_dummy2 = 1;
+    }
+    if($dst_dummy3 == 0 && $show->{'START_TIME'} >= 10800) {
+      push @carts, { NUMBER => 20, START_TIME => 10800000, TRANS_TYPE => 2, TIME_TYPE => 1 };
+      $dst_dummy3 = 1;
+    }
     push @carts, { NUMBER => $show->{'ID'}, START_TIME => $show->{'START_TIME'}*1000, TRANS_TYPE => 2, TIME_TYPE => 1 };
   }
 
@@ -1375,6 +1388,8 @@ sub get_schedule_log
 
   my @show_dbs;
   while(my ($start_time, $cart_number) = $sth->fetchrow_array()) {
+    next if ($cart_number == 20); ## Daylight Savings Hack
+
     my $entry = {};
     $entry->{'ID'} = $cart_number;
     my ($title, $len, $status, $errorstring) = get_show_title_and_len($ctx, $cart_number);
-- 
cgit v0.10.2