--- libs/libmythtv/datadirect.cpp.before-runtime	2008-01-09 16:45:26.000000000 -0500
+++ libs/libmythtv/datadirect.cpp	2009-06-26 15:41:52.966867566 -0400
@@ -221,11 +221,11 @@
 
         query.prepare("INSERT INTO dd_program (programid, title, subtitle, "
                       "description, showtype, category_type, mpaarating, "
-                      "starrating, stars, runtime, year, seriesid, colorcode, "
+                      "starrating, stars, runtime, sd_runtime, year, seriesid, colorcode, "
                       "syndicatedepisodenumber, originalairdate) "
                       "VALUES(:PROGRAMID,:TITLE,:SUBTITLE,:DESCRIPTION,"
                       ":SHOWTYPE,:CATTYPE,:MPAARATING,:STARRATING,:STARS,"
-                      ":RUNTIME,:YEAR,:SERIESID,:COLORCODE,:SYNDNUM,"
+                      ":RUNTIME,:SD_RUNTIME,:YEAR,:SERIESID,:COLORCODE,:SYNDNUM,"
                       ":ORIGINALAIRDATE);");
         query.bindValue(":PROGRAMID", curr_program.programid);
         query.bindValue(":TITLE", curr_program.title.utf8());
@@ -237,6 +237,7 @@
         query.bindValue(":STARRATING", curr_program.starRating);
         query.bindValue(":STARS", staravg);
         query.bindValue(":RUNTIME", curr_program.duration);
+        query.bindValue(":SD_RUNTIME", curr_program.sd_runtime);
         query.bindValue(":YEAR", curr_program.year);
         query.bindValue(":SERIESID", curr_program.seriesid);
         query.bindValue(":COLORCODE", curr_program.colorcode);
@@ -295,6 +296,7 @@
  
 bool DDStructureParser::characters(const QString& pchars) 
 {
+    int h, m;
     // cerr << "Characters : " << pchars << "\n";
     if (pchars.stripWhiteSpace().isEmpty())
         return true;
@@ -352,9 +354,11 @@
     else if (currtagname == "runTime") 
     {
         QString runtimestr = pchars;
-        QTime runtime = QTime(runtimestr.mid(2,2).toInt(),
-                              runtimestr.mid(5,2).toInt(), 0, 0);
+
+        QTime runtime = QTime(h = runtimestr.mid(2,2).toInt(),
+                              m = runtimestr.mid(5,2).toInt(), 0, 0);
         curr_program.duration = runtime;
+        curr_program.sd_runtime = h * 60 + m;
     }
     else if (currtagname == "originalAirDate") 
     {
@@ -412,13 +416,13 @@
                        "closecaptioned, partnumber, parttotal, seriesid, "
                        "originalairdate, showtype, category_type, colorcode, "
                        "syndicatedepisodenumber, tvrating, mpaarating, "
-                       "programid) "
+                       "programid, sd_runtime) "
                        "SELECT chanid, scheduletime, endtime, title, "
                        "subtitle, description, year, stars, repeat, stereo, "
                        "subtitled, hdtv, closecaptioned, partnumber, "
                        "parttotal, seriesid, originalairdate, showtype, "
                        "category_type, colorcode, syndicatedepisodenumber, "
-                       "tvrating, mpaarating, dd_program.programid "
+                       "tvrating, mpaarating, dd_program.programid, sd_runtime "
                        "FROM channel, dd_schedule, dd_program WHERE "
                        " ( (dd_schedule.programid = dd_program.programid) AND "
                        "   (channel.xmltvid = dd_schedule.stationid) AND "
@@ -625,6 +629,7 @@
     table = "( programid char(20) NOT NULL, seriesid char(12), "
             "title varchar(120), subtitle varchar(150), description text, "
             "mpaarating char(5), starrating char(5), runtime time, "
+            "sd_runtime smallint unsigned, "
             "year char(4), showtype char(30), category_type char(64), "
             "colorcode char(20), originalairdate date, "
             "syndicatedepisodenumber char(20), stars float unsigned, "
@@ -634,6 +639,7 @@
     table = "( chanid int unsigned NOT NULL, starttime datetime NOT NULL, "
             "endtime datetime, title varchar(128), subtitle varchar(128), "
             "description text, category varchar(64), "
+            "sd_runtime smallint unsigned, "
             "category_type varchar(64), airdate year, stars float unsigned, "
             "previouslyshown tinyint, repeat bool, stereo bool, "
             "subtitled bool, hdtv bool,  closecaptioned bool, partnumber int, "
--- libs/libmythtv/datadirect.h.before-runtime	2005-05-04 15:40:07.000000000 -0400
+++ libs/libmythtv/datadirect.h	2009-06-13 00:19:19.558883882 -0400
@@ -88,6 +88,7 @@
         stationid = "";
         time = QDateTime();
         duration = QTime();
+        sd_runtime = 0;
         repeat = false;
         stereo = false;
         subtitled = false;
@@ -102,6 +103,7 @@
     QString stationid; // 12
     QDateTime time; 
     QTime duration;
+    int sd_runtime;
     bool repeat;
     bool stereo;
     bool subtitled;
@@ -127,6 +129,7 @@
         mpaaRating = "";
         starRating = "";
         duration = QTime();
+        sd_runtime = 0;
         year = "";
         showtype = "";
         colorcode = "";
@@ -142,6 +145,7 @@
     QString mpaaRating; // 5
     QString starRating; // 5 
     QTime duration;
+    int sd_runtime;
     QString year; // 4
     QString showtype; // 30
     QString colorcode; // 20
--- programs/mythfilldatabase/filldata.cpp.before-runtime	2005-05-05 03:10:39.000000000 -0400
+++ programs/mythfilldatabase/filldata.cpp	2009-06-12 13:12:14.820790191 -0400
@@ -125,6 +125,7 @@
                                       colorcode = other.colorcode;
                                       syndicatedepisodenumber = other.syndicatedepisodenumber;
                                       programid = other.programid;
+				      sd_runtime = other.sd_runtime;
         
                                       clumpidx = other.clumpidx;
                                       clumpmax = other.clumpmax;
@@ -160,6 +161,7 @@
     QString colorcode;
     QString syndicatedepisodenumber;
     QString programid;
+    QString sd_runtime;
 
     QString clumpidx;
     QString clumpmax;
@@ -885,13 +887,13 @@
                     "airdate, stars, previouslyshown, stereo, subtitled, "
                     "hdtv, closecaptioned, partnumber, parttotal, seriesid, "
                     "originalairdate, colorcode, syndicatedepisodenumber, "
-                    "programid) "
+                    "sd_runtime, programid) "
                     "SELECT chanid, starttime, endtime, "
                     "title, subtitle, description, "
                     "showtype, dd_genre.class, category_type, "
                     "airdate, stars, previouslyshown, stereo, subtitled, "
                     "hdtv, closecaptioned, partnumber, parttotal, seriesid, "
-                    "originalairdate, colorcode, syndicatedepisodenumber, "
+                    "originalairdate, colorcode, syndicatedepisodenumber, sd_runtime, "
                     "dd_v_program.programid FROM dd_v_program "
                     "LEFT JOIN dd_genre ON ("
                     "dd_v_program.programid = dd_genre.programid AND "
@@ -2251,6 +2253,7 @@
                           "showtype=:SHOWTYPE AND "
                           "colorcode=:COLORCODE AND "
                           "syndicatedepisodenumber=:SYNDICATEDEPISODENUMBER AND "
+                          "sd_runtime=:SD_RUNTIME AND "
                           "programid=:PROGRAMID;");
             query.bindValue(":CHANID", chanid);
             query.bindValue(":START", startstr);
@@ -2274,6 +2277,7 @@
             query.bindValue(":SHOWTYPE", (*i).showtype);
             query.bindValue(":COLORCODE", (*i).colorcode);
             query.bindValue(":SYNDICATEDEPISODENUMBER", (*i).syndicatedepisodenumber);
+            query.bindValue(":SD_RUNTIME", (*i).sd_runtime);
             query.bindValue(":PROGRAMID", (*i).programid);
             query.exec();
 
@@ -2344,13 +2348,13 @@
                           "airdate,stars,previouslyshown,title_pronounce,stereo,"
                           "subtitled,hdtv,closecaptioned,partnumber,parttotal,"
                           "seriesid,originalairdate,showtype,colorcode,"
-                          "syndicatedepisodenumber,programid) "
+                          "syndicatedepisodenumber,sd_runtime,programid) "
                           "VALUES(:CHANID,:STARTTIME,:ENDTIME,:TITLE,"
                           ":SUBTITLE,:DESCRIPTION,:CATEGORY,:CATEGORY_TYPE,:AIRDATE,:STARS,"
                           ":PREVIOUSLYSHOWN,:TITLE_PRONOUNCE,:STEREO,:SUBTITLED,"
                           ":HDTV,:CLOSECAPTIONED,:PARTNUMBER,:PARTTOTAL,:SERIESID,"
                           ":ORIGINALAIRDATE,:SHOWTYPE,:COLORCODE,:SYNDICATEDEPISODENUMBER,"
-                          ":PROGRAMID);");
+                          ":SD_RUNTIME,:PROGRAMID);");
             query.bindValue(":CHANID", chanid);
             query.bindValue(":STARTTIME", startstr);
             query.bindValue(":ENDTIME", endstr);
@@ -2374,6 +2378,7 @@
             query.bindValue(":SHOWTYPE", (*i).showtype);
             query.bindValue(":COLORCODE", (*i).colorcode);
             query.bindValue(":SYNDICATEDEPISODENUMBER", (*i).syndicatedepisodenumber);
+            query.bindValue(":SD_RUNTIME", (*i).sd_runtime);
             query.bindValue(":PROGRAMID", (*i).programid);
             if (!query.exec())
             {
--- /usr/share/mythtv/mythweb/themes/Default/program_detail.php	2009-06-19 02:38:18.000000000 -0400
+++ /usr/share/mythtv/mythweb/themes/Default/program_detail.php.before-runtime	2005-09-24 00:19:00.000000000 -0400
@@ -55,41 +55,8 @@
                 echo ' ('.t('Rerun').')';
             echo '<br />'
                 .t('$1 to $2', strftime('%r', $schedule->starttime), strftime('%r', $schedule->endtime));
-            if ($program) {
+            if ($program)
                 echo ' ('.tn('$1 min', '$1 mins', intval($program->length/60)).')';
-		// If sd_runtime not in table, blow out visibly by barfing on later use!  Can only happen if the table schema isn't in sync w/this function, which shouldn't happen.
-		// ($result will be a boolean false if this erred, or a resource if this succeeded.)
-		$result = mysql_query("SELECT sd_runtime FROM program WHERE chanid = '$program->chanid' AND starttime = from_unixtime($schedule->starttime)");
-		list($sd_runtime) = mysql_fetch_row($result);
-                mysql_free_result($result);	
-		// We must get the ORIGINAL (unpadded!) scheduled time and compare it to sd_runtime, for two reasons:
-		// (a) If the program overflows its timeslot, I want to know -even if- it's apparently padded enough,
-		//     because it might be that the padding -just- compensates for the putative overflow but then isn't
-		//     also doing its job of compensating for clock skew---hence an overflow eats into our clock skew
-		//     allowance and might eat it up entirely.
-		// (b) Any preroll padding -can't- be counted as helping to compensate for an overflow, since by definition
-		//     overflows can only push the end later---having padding before it starts can't help us at all.
-		// Once we've compared the original scheduling with sd_runtime, we can then -also- see if our postroll claims to help.
-		$scheduled_length = ($schedule->endtime - $schedule->starttime) / 60;
-		$overflow = ($sd_runtime - $scheduled_length);
-		if ($overflow > 0) {
-		  // The runtime is larger than the scheduled time, so it has definitely overflowed.
-		  // If it's larger than even the postroll-padded time, panic!
-		  // Note that the colors below should be in CSS, not here.  And, for the first time
-		  // since 12/10/94 and Netscape 1.0, I've -finally- found a use for the <blink> tag...
-		  $postroll = is_null($program->recendts) ? 0 : ($program->recendts - $schedule->endtime) / 60;
-		  $postrolled_overflow = $overflow - $postroll;
-		  if ($postrolled_overflow >= 0) {	// >= and not just > because, even if it's exactly right, this means we've lost our postroll margin, so complain vociferously.
-		    $extra = ($postroll > 0) ? " even w/$postroll postroll" : "";
-		    $pack  = ($postroll > 0) ? "<br>" : "&nbsp;";
-		    echo " $pack<blink><font color=red>($postrolled_overflow min over$extra!)</font></blink>";
-		    }
-		  else {				// Not over including the postroll, but we should still call attention to it.
-		    $mpo = -$postrolled_overflow;
-		    echo " <br><font color=red>($overflow min over, but $postroll min postroll gives $mpo min safety)</font>";
-		    }
-		  }
-		}
             if ($_GET['recordid'])
                 echo "</span>";
             echo "<br />\n";
