[mythtv] Display Old Original Air Dates?

Bruce Markey bjm at lvcm.com
Tue Feb 27 19:22:44 UTC 2007


Tim Musa wrote:
> Maybe this should be a bug ticket, but I figured I'd check here first.  
> Currently all of my old TV shows (pre-1970) show up with and 
> %ORIGINALAIRDATE% of 12/31/1969.  This causes the "Sort by Air Date" to 
> not sort the episodes correctly.  The date is correct in the MySQL 
> database, so I know the data is correct.  However, somewhere in the 
> display process the date gets cut off at 1/1/1970.  ID did some playing 
> around with modifying the date in the database and found that dates 
> display correctly between 1/1/1970 and 1/18/2038.  I'm guessing that 
> this isn't a quick fix, but was hoping to find out if a fix was possible.

Your assumption is that all programs specify an original air
day from the source. This is not correct. 

mysql> select count(*) from program;
+----------+
| count(*) |
+----------+
|    45038 |
+----------+
1 row in set (0.00 sec)

mysql>
mysql> select count(*) from program where originalairdate='0000-00-00';
+----------+
| count(*) |
+----------+
|    13844 |
+----------+
1 row in set (0.00 sec)

mysql> select originalairdate,generic,title from program where originalairdate > '0000-00-00' order by originalairdate limit 10;
+-----------------+---------+-----------------+
| originalairdate | generic | title           |
+-----------------+---------+-----------------+
| 1950-02-16      |       1 | What's My Line? |
| 1950-02-16      |       1 | What's My Line? |
| 1950-02-16      |       1 | What's My Line? |
| 1951-10-15      |       0 | I Love Lucy     |
| 1951-10-22      |       0 | I Love Lucy     |
| 1951-10-29      |       0 | I Love Lucy     |
| 1951-11-03      |       0 | I Love Lucy     |
| 1951-11-12      |       0 | I Love Lucy     |
| 1951-11-19      |       0 | I Love Lucy     |
| 1951-11-26      |       0 | I Love Lucy     |
+-----------------+---------+-----------------+
10 rows in set (0.13 sec)

Because there are rows where the data in invalid, the program
info has a flag for hasAirDate which defaults to false. If this
is false, the date is meaningless and should be ignored.

Midnight Jan. 1, 1970 GMT is the epoch for UNIX/C from Ritchie
and Thompson at Bell Labs. Dates are stored as seconds relative
to this time so whenever you see 12/31/1969 west of Greenwich,
it means that the seconds since epoch is set to zero.

The UI sting you mentioned should be blank if the date is not
valid:

    if (hasAirDate)
    {
        progMap["originalairdate"] = originalAirDate.toString(dateFormat);
        progMap["shortoriginalairdate"] =
                                originalAirDate.toString(shortDateFormat);
    }
    else
    {
        progMap["originalairdate"] = "";
        progMap["shortoriginalairdate"] = "";
    }

And the "Sort by Air Date" uses the recording date is there
is no OAD:

    if (a->hasAirDate)
        dt1 = a->originalAirDate;
    else
        dt1 = a->startts.date();


--  bjm 


More information about the mythtv-dev mailing list